Problem/Motivation
The admin menu list (/admin/structure/menu) appears to sort alphabetically by menu title until the list exceeds one page. When the number of menus exceeds 50, the list is paginated and menus are then sorted 1) by machine name across all menus, then 2) alphabetically by menu title per listing page. If menu titles are changed such that they no longer align with the machine name, they can be difficult to find across a multipage list.
Steps to Reproduce
- Create/generate more than 50 menus (e.g. with devel)
- Change an early menu title on page 1 such that it should sort to the end of the entire menu list
You'll find that it only moves to the bottom of page 1, not to the end of the last page
Proposed resolution
Implement/override getEntityIds() in MenuListBuilder.php to explicitly sort the list query by menu title ('label').
Remaining tasks
Write a patch
Tests
Review
Commit
User interface changes
Menu list will be sorted alphabetically by menu title across the entire menu list.
API changes
None.
Data model changes
None.
Release notes snippet
TBD
| Comment | File | Size | Author |
|---|---|---|---|
| #48 | interdiff_20-48.txt | 5.68 KB | ranjith_kumar_k_u |
| #48 | 3070721-48.patch | 3.28 KB | ranjith_kumar_k_u |
| #23 | AfterPatch#20.png | 25.96 KB | asha nair |
| #23 | BeforePatch#20.png | 27.72 KB | asha nair |
| #20 | interdiff_17-20.txt | 1.91 KB | ranjith_kumar_k_u |
Comments
Comment #2
justcaldwellPatch attached.
Comment #6
abhijith s commentedApplied patch #2 on 9.2.x and it works fine.The menu items are sorted by title in entire page after this patch.Adding screenshots
Before(Menu starting with 'z' on first page ):

After(Now the same menu items appers correctly as last item):

Comment #7
abhijith s commentedComment #8
quietone commentedJust a brief look.
I see that the patch also has a coding standard error and there is no test for this. Adding tag for the test.
Comment #9
anmolgoyal74 commentedUpdated CS.
Comment #10
anmolgoyal74 commentedComment #15
smustgrave 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.
This was tagged for tests in #8 that still need to happen.
Did not review the code.
Comment #16
danielvezaConfirmed the issue exists in manual testing. Added a test.
Comment #17
danielvezaFixing the code standards.
Comment #19
smustgrave commentedFailure in #17 seems legit
Comment #20
ranjith_kumar_k_u commentedFixed test failures.
Comment #21
ranjith_kumar_k_u commentedComment #22
ranjith_kumar_k_u commentedComment #23
asha nair commentedApplied patch #21 in 10.x successfully and it fixes the issue. Now it sorts the entire menu list after updating. Adding screenshots for reference.
Comment #24
smustgrave commentedNot 100% sold on the test fix. As they use to pass before and this change shouldn't have caused those to fail. But will let the committer decide.
Comment #47
catchI don't think config entities can have query access, so this is redundant and can be removed. phpstan should no longer warn about this too, but it was at one point.
Is there an existing test that we could add an assertion to?
Comment #48
ranjith_kumar_k_u commentedAddressed #47, please review
Comment #49
smustgrave commentedPoints in #47 appear to be addressed.
Comment #50
longwaveCommitted 6ec16df and pushed to 11.x. Thanks!