Problem/Motivation
If you test a page in the admin ui with ARC Toolkit it finds duplicate IDs for the top level menu items Live (for the workspaces module) and Help . Each has the ID navigation-link-. That is not in line with WCAG2.2 SC4.1.2. The problem only applies to the default Live workspace. If you switch to another the problem does not apply and there are unique IDs.
*Was not sure against which component i should file this issue. but i went with the navigation module for now. please reassign if there is a more suitable component.
Steps to reproduce
- Do a fresh site install.
- Leave caching and aggregation enabled like normal
- Enable the Navigation and the Workspaces UI modules
- Go to for example
admin/modules - Check
idattribute on the thelielements wrapping the top level menu itemsLive(the default workspace) andHelp
Proposed resolution
Use unique IDs for the top level menu items Live and Help
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | issue-3570505-10-empty-plugin-ids-exposed.png | 103.58 KB | kentr |
| #7 | Administration___Drush_Site-Install_and_navigation-menu_html_twig_—_drupal.png | 358.79 KB | mherchel |
Issue fork drupal-3570505
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3570505-the-top-level
changes, plain diff MR !14732
Comments
Comment #2
mherchelHad Zoom with @mgifford, @rkoller, and @kat-shaw.
I'm having difficulty reproducing this. The |clean_unique_id is adding a number at the end of the ID, so they're different.
Comment #3
mgiffordIn discussion with @mherchel @rkoller & @kat-shaw we decided that this was a barrier if we can replicate it. We were having trouble tracking down the source of the problem.
This would fall under
https://www.w3.org/WAI/WCAG21/Understanding/name-role-value.html
Comment #4
rkollerI was able to reproduce with the
main-devbranch. did a composer create project. one detail to note. on the very first page load when there is no caching yet checking the list element wrapping the menu item for the workspaces module the ID is correctlynavigation-link---5on any subsequent request the ID becomesnavigation-link-. If you do adrush cron the first page load right after the ID becomesnavigation-link---5again for the list element wrapping the menu item for the workspaces module for one page request. then it is back tonavigation-link-.Comment #5
mherchelThis looks like a bug in |clean_unique_id.
That being said, we can work around it with random()
Comment #6
mherchelI am able to reproduce this exactly like @rkoller in #4.
I wasn't able to reproduce prior because I generally have all caching disabled.
Comment #7
mherchelPushed a commit that uses Twig's
random()function instead of the|clean_unique_idfilter.Comment #9
mherchelUpdating IS and title.
Comment #10
kentr commentedEven with workspaces enabled, I'm not seeing
LiveBut for the
Helpitem, the underlying probem appears to be thatitem.original_link.pluginIdis empty.This explains why
Shortcutshasnavigation-link---<digit>, even though it's not a duplicate.Here's a screenshot with
item.original_link.pluginIdoutput on the page, between the plus signs (+).For
HelpandShortcuts, it's blank between the plus signs.To me, the fix looks like getting
item.original_link.pluginIdto have values for those items.Comment #11
mherchelNote you need to enable workspaces_ui module.
Comment #12
mherchelThere's no reason that
item.original_link.pluginIdneeds to be in theID. The requirement is that the IDs are unique. Plus there will likely be multiple list-items with the sameitem.original_link.pluginIdComment #13
mherchelTests updated to account for random numbers in IDs (and associated
aria-controlsattributes)Comment #14
kentr commentedIf that's the case, why not remove
item.original_link.pluginIdfrom the template?To me, the inconsistency of some
IDattributes with and some without the semantic part makes it look like a bug or like someone forgot something.Comment #15
kentr commentedFYI, the pipeline has failures.
I didn't have time to look at the failures in depth
Comment #16
mherchelNot sure why it was added. I guess I didn't remove it because it was out of scope? Maybe we could make a followup to remove it? TBH, I'm not sure it matters. But we could.
Comment #17
mherchelComment #18
mherchelPushed a fix to the selectors in the tests.
Comment #19
mherchelOne more note on this is that the plugin ID is used within the tests (see below). We could move the plugin id to an attribute if needed. but just FYI, I think this would complicate things for minimal gain.
https://git.drupalcode.org/project/drupal/-/blob/9da49dfa40824c92b8670fd...
Comment #20
kentr commentedIn case it matters,
stable9is also affected by this.I set
stable9as the administration theme and saw the problem, so perhaps that means any admin theme created fromstable9per the current docs will be affected.Starterkit uses
stable9as a base. Unsure if that will also cause problems.Comment #21
smustgrave commentedNever know where stable9 lands but since this is the only other navigation-menu.html.twig in core maybe we should just update here too.
Rest of the changes LGTM and @mherchel probably good to RTBC yourself after the change.
Comment #22
kentr commentedI copied the change to
stable9. When pipeline passes it should be ready for review.Comment #23
kentr commentedOr, based on #21, RTBC when the pipeline passes.
Comment #24
mherchelPipeline passed. RTBC per #21 and #22
Comment #25
catchDon't want to hold this up but on the other hand it really seems like a duplicate of #1852090: Cached render elements can have duplicate HTML IDs.
Comment #26
kentr commentedI'm experimenting with #1852090: Cached render elements can have duplicate HTML IDs.
Comment #27
kentr commentedI don't think this is really a duplicate of #1852090: Cached render elements can have duplicate HTML IDs.
Navigation is the only place in core that I can find currently using
clean_unique_id.There are other ways to generate a unique ID for cases like this.
random()works, but concatenating the hierarchy and the link text would also probably work (like namespacing).I think
clean_unique_idjust isn't ready for this type of use.Comment #28
kentr commentedOr rather, the button text in this case.
Comment #31
catchThanks for looking at #1852090: Cached render elements can have duplicate HTML IDs. I still think we should be fixing that generically across core, but we can open a follow-up issue to standardize navigation on whatever ends up implemented in that issue.
Committed/pushed to main and 11.x, thanks!
Comment #34
kentr commentedSame. And even though it's a global problem, it's acutely causing accessibility issues with forms.