Problem/Motivation
On the "mobile" version, when the sidebar is closed, the elements within the sidebar are still focusable and in the tab ring.
Tabbing into the sidebar causes the focus to disappear.
The submenu toggle buttons can be activated, but the submenus are hidden.
The items are still available in the aural interface (originally reported by @rkoller: #3543541: [PP-1] on the mobile viewport with the navigation sidebar collapsed the menu items are still available in the aural interface).

WCAG success criteria
- 2.1.1: Keyboard (Level A)
- 2.4.11 Focus Not Obscured (Minimum) (Level AA)
- 1.3.1 Info and Relationships (Level A)
- 1.3.2 Meaningful Sequence (Level A)
Related technique
Steps to reproduce
- Enable the Navigation module.
- Log in as admin.
- Reduce the window width so that the "mobile" sidebar is active.
- Ensure that the sidebar is closed ("Expand sidebar" button is visible).
- Start tabbing from the top of the page before the "Expand sidebar" button, and continue past the "Expand sidebar" button.
Expected
After reaching the "Expand sidebar" button, focus moves to the next visible focusable item on the page.
Actual
Focus disappears as it moves into the closed sidebar.
Proposed resolution
- When the mobile sidebar is closed, completely hide it with
visibility: hidden. - Add
visibilityto the sidebar's CSStransitionso that open & close animations are preserved. - Ensure this does not affect the desktop sidebar.
The attached videos demonstrate before / after with visibility: hidden.
Remaining tasks
User interface changes
- The focus will stay on visible elements.
- Elements in the collapsed sidebar will not be available in the aural interface.
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | 63b511bb62385a9e25f4db3f03324933.gif | 1.57 MB | finnsky |
| #30 | after.mp4 | 418 KB | rkoller |
| #30 | before.mp4 | 892.14 KB | rkoller |
| #25 | issue-3541910-25-using-animated-visibility-only.480p.mov | 1022.98 KB | kentr |
| #14 | Issue-3541910-after.gif | 979.6 KB | sandip |
Issue fork drupal-3541910
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:
Comments
Comment #2
kentr commentedThere's overlap with #3543541: [PP-1] on the mobile viewport with the navigation sidebar collapsed the menu items are still available in the aural interface.
The proposed fix here does remove them from the VoiceOver rotor, so I think it hides them from the aural interface.
Comment #3
catchPostponing #3543541: [PP-1] on the mobile viewport with the navigation sidebar collapsed the menu items are still available in the aural interface on this issue and bumping to major.
I can't see why we'd want to allow tabbing into hidden elements when the sidebar is collapsed, that's what the expand button is for, so the propose resolution makes sense to me.
Comment #6
shqshqnk commentedFixed the issue with hidden navigation links still focusable on mobile by hiding them with visibility: hidden when the sidebar is collapsed.
Comment #7
shqshqnk commentedComment #8
smustgrave commentedThink we could maybe expand an existing javascript test to test for focus.
Comment #9
catchLet's get some manual testing of this first before trying to write automated tests for it.
Comment #10
finnsky commentedI think this needs to be fixed differently.
Neither
display:none
nor
visibility:hidden
will work here because we have a collapse animation. It's gone now. Perhaps we could add visibility:hidden with some delay.
Comment #11
finnsky commentedComment #12
finnsky commentedI think it's better to do this through
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attri...
We already have examples of use in the module.
For example, we did something similar here
https://www.drupal.org/project/navigation/issues/3436130
Comment #13
sandip commentedI am working on it based on the suggestion at #12
Comment #14
sandip commentedPlease review the changes. Adding a gif to see after changes.
Comment #15
mherchelvisibilitysupports CSS transitions. So it can work with visibility (we do so within Olivero).But, the solution within the MR (toggling
inertvia JS) works just as well.Tested this out, and works well!
Comment #16
mherchelSetting back to NW. Just discovered that at wide widths, and the navigation is in its "narrow" mode, it's set to
inert, which makes it inoperable.Comment #17
nod_And the tests caught it so we do have some test for this somehow :)
Comment #18
sandip commentedYes i got the issue i am looking into it
Comment #19
sandip commentedI removed the inert toggle for desktop screens as it isn’t needed there, and everything is working as expected now. The only remaining issue is that when I change the screen width in the browser’s DevTools, the
toggleTriggersfunction doesn’t run on screen width change, so I am thinking we may need to calltoggleTriggersinside a screen change listener, but I am not sure if thats the best approach.Does it make sense to call
toggleTriggerson viewport changes or is there a better alternative? Looking for suggestions or best practices here.Comment #20
kentr commentedWith the issues in #19:
Using a listener to detect width changes sounds complex and flaky.
Animating
visibility(#15) sounds feasible and much simpler than using JS.Or if animating
visibilityisn't acceptable, what about usingvisibilityon a child of the animated element (if there is a single child element that contains the problem)?Comment #21
kentr commentedPlaying around in devtools on
11.x(without this MR), the following CSS appears to fix the tabbing problem while preserving the animations.It can be cleaned up a little.
Comment #22
mherchel@kentr Do you want to open up a new MR?
If you're not familiar with either the MR process or contributing code to core, I'm more than happy to help!
Comment #23
kentr commented@mherchel: Sure. I didn't want to step on any toes.
Comment #25
kentr commentedMR !14200 has test failures, but the ones I saw look unrelated.
I've run some of them locally with no issues. I'll hazard a guess that they're related to package download problems in CI. Maybe there are still DDOS problems.
I reran some of them on gitlab, and am rerunning others now.
I'll look more into the failures when I have a chance, if someone else doesn't get to it first.
Here's a screen recording showing tabbing past the closed sidebar (rather than into it), tabbing through the expanded sidebar, the open & close actions, and tabbing into the "desktop" sidebar.
Comment #26
catchTest failures looked random, re-ran the two remaining failed jobs, this looks like it needs review.
Comment #27
kentr commentedI think the test failures are related to #3557585: Update to Composer 2.9.2.
Comment #28
kentr commentedAh, yeah. The fork / branch is behind.
I'll rebase it.
Comment #29
kentr commentedRebased.
Comment #30
rkollerI'Ve already tested this last night. made me already close the postponed #3543541: [PP-1] on the mobile viewport with the navigation sidebar collapsed the menu items are still available in the aural interface as a duplicate cuz this issue also fixes the problem in the aural interface. tested in the latest safari, firefox, and edge on macOS 26.2, all work. i'll also add the before and after videos i've created before i saw @kentr already uploaded one. i upload them anyway cuz they illustrate aside the tab behavior also the aural interface in voiceover as well as the available list of links in the voiceover rotor. tests are green. so from my manual testing perspective a +1 for RTBC. thank you for working on that @kentr! i leave it to needs review cuz i am not qualified to review the code.
Comment #31
finnsky commentedI started testing and found another bug with this animation.
The navigation block width is set incorrectly for different screen sizes. This becomes apparent when I increase the animation time.
I decided to fix it here to completely resolve this issue.
Otherwise, everything is ready for RTBC, I don’t mark it that way because I added the code myself
Comment #32
kentr commentedWhat about an automated test?
I updated the IS and tags to encompass #3543541: [PP-1] on the mobile viewport with the navigation sidebar collapsed the menu items are still available in the aural interface.
@rkoller, please change it as needed.
Also:
Comment #33
finnsky commentedRebased
IDK. Probably we need to write them.
Comment #34
catchIf we have an existing automated test that can be adapted to cover this, that's great. If it needs entirely new test coverage, I'd be happy to add that in a follow-up given this has had extensive manual testing. It seems like one of the bigger remaining navigation accessibility issues (at least the aural interface part, not sure how important keyboard navigation on mobile is in practice) so would be good to get in if people are otherwise happy.
Comment #36
quietone commentedComment #38
lauriiiI personally think this is fine to commit without the automated tests. Confirmed this manually both with the steps from the issue summary and with screen reader.
Comment #41
catchOpened #3570453: Test coverage for closed sidebar focus in Navigation for test coverage, would be great to do that with playwright or a functional js + Axe test if we can.
While I'm not qualified to review the CSS changes, this all seems sensible and has had multiple rounds of review and testing, so I'm happy going head here. Committed/pushed to main and 11.x, thanks!
Do we think this can/should be backported to 11.3.x? If so happy to do that but a bit wary due to some other Navigation CSS regressions in 11.3.0 due to the reset, so would rather here from someone else that it'll be fine before doing so (and maybe shortly after next week's patch release instead of shortly before). Moving to 'to be ported' for that.
Comment #44
smustgrave commentedActually since it's been 2 months do we want to backport anymore?
Comment #45
smustgrave commentedGoing to go ahead and mark this fixed. Since 11.4 is closer to coming out then before. If I'm wrong let me know.