Problem/Motivation
The 'Edit' link for custom menu links does not contain the language prefix of the current language, so it always takes you to the edit page in the default language.
Steps to reproduce
- Install Drupal
- Enable Language and Configuration translation
- Create a node and add a link to the main menu
- Switch to another language and go to the main menu admin page (e.g.
/fr/admin/structure/menu
) - See that the 'Edit' button for the default home link points to
/fr/admin/structure/menu/link/standard.front_page/edit
- See that the 'Edit' button for the custom link points to
/admin/structure/menu/item/1/edit
Expected result would be the edit link points to /fr/admin/structure/menu/item/1/edit
to reflect the current language.
Proposed resolution
Ensure that the menu edit links for custom menu items use the current language prefix.
Remaining tasks
- Write patch
- Review
User interface changes
Update the menu edit links to add the current language prefix.
Comment | File | Size | Author |
---|---|---|---|
#32 | interdiff-30-31.txt | 2.64 KB | codersukanta |
#32 | 2623254-31.patch | 6.26 KB | codersukanta |
#30 | interdiff-2623254-28-30.txt | 1.01 KB | mohit_aghera |
#30 | 2623254-30.patch | 7.61 KB | mohit_aghera |
#28 | interdiff_23_28.txt | 4.29 KB | KapilV |
Comments
Comment #4
pameeela CreditAttribution: pameeela commentedI have updated the IS to distill this down to a simple, reproducible issue.
Comment #5
bbu23 CreditAttribution: bbu23 at Ninja Coders commentedHello,
I'm providing a patch for this, but since this is a core issue, I'm not sure about the approach. I found two places where I can fix this, and chose the plugin because I thought it's more appropriate for reusability of the methods that I've updated.
The other place would have been in the
\Drupal\menu_ui\MenuForm.php
fileBut this second solution would apply only for the tree, so not everywhere, that's why I chose the first solution.
Comment #6
bbu23 CreditAttribution: bbu23 at Ninja Coders commentedComment #8
jonathanshawYour patch looks good to me @bbu23, although menu is not an area I know much about. This does need test coverage though, and I'm not sure if any test in the menu_link_content module is a good one to base the test on. There is also a test failure to fix.
Comment #9
mohit_aghera CreditAttribution: mohit_aghera as a volunteer and at Axelerant commentedTest cases for initial review.
Comment #11
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedLooks like unrelated failure.
Triggered the test again.
Comment #13
chandrashekhar_srijan CreditAttribution: chandrashekhar_srijan at Srijan | A Material+ Company for Drupal India Association commentedUploading a test only patch to see if it fixes the issue.
As mentioned in #11 I have this test passed on my local.
Comment #14
mohit_aghera CreditAttribution: mohit_aghera as a volunteer and at Axelerant commentedComment #16
quietone CreditAttribution: quietone as a volunteer commentedI just tried to reproduce this on a minimal install of 9.1.x and failed. In step 6, the result I get is the expected result, the edit link points to
/it/admin/structure/menu/item/1/edit?destination=/it/admin/structure/menu. Since it was a minimal install there was no 'home' link to test as in step 5.
Ignore the above. I can reproduce it.
Comment #17
quietone CreditAttribution: quietone as a volunteer commentedHaving a go at this. I made a patch with the following changes.
Don't think this is needed.
The docs for Url::fromRoute direct to \Drupal\Core\Url::fromUri() which doesn't have a 'langcode' property. It does have a language property which is an object.
Comment #18
amateescu CreditAttribution: amateescu as a volunteer commentedThe bug reported here is the "standard" practice throughout the whole entity system (e.g. you can observe this behavior for nodes too), so any change needs to be made on a more general level, not just for menu links.
Comment #20
mohit_aghera CreditAttribution: mohit_aghera as a volunteer and at Axelerant commented@quietone
I've uploaded initial patch where we are modifying "getDefaultOperations()" method in EntityListBuilder class.
I was not able to use dependency injection because it will potentially affect all the classes that extends EntityListBuilder. It may affect many custom and contributed modules.
Triggering tests to evaluate all the failures and fix accordingly.
Comment #23
mohit_aghera CreditAttribution: mohit_aghera as a volunteer and at Axelerant commentedComment #25
jonathanshawSpecifying the link type as "edit-form", when previously we used the default, seems like a significant change. Maybe I'm missing something.
Comment #26
pameeela CreditAttribution: pameeela commentedI set this to the wrong branch, moving back.
Comment #27
KapilV CreditAttribution: KapilV as a volunteer and commentedComment #28
KapilV CreditAttribution: KapilV as a volunteer and commentedHear an updated patch.
Comment #30
mohit_aghera CreditAttribution: mohit_aghera as a volunteer and at Axelerant commentedFixing test case failures and adding entity creation for the menu link content entity.
Comment #32
codersukanta CreditAttribution: codersukanta at Srijan | A Material+ Company for Drupal India Association commentedFixed issues in the patch.
I have tried to keep the changes restrained within scope of the issue, for this I have undo the changes at entity level files.
Comment #33
mohit_aghera CreditAttribution: mohit_aghera commentedComment #37
borisson_I disagree with the approach taken in #32, according to @amateescu in #18 we need to do this at the entity level instead of just for menu links.
So I think the next step here is to update the issue summary to make it more generalized and then we should try to continue on the patch in #30
Comment #38
jonathanshaw#37 +1
Comment #40
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
have to agree with #37 so moving to NW for that work.