Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
Olivero theme
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Apr 2021 at 15:34 UTC
Updated:
2 Jun 2021 at 14:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
bnjmnmComment #3
bnjmnmComment #5
mherchelThis should be pretty straightforward
Comment #6
mherchelMinor change in comment :D
Comment #7
gauravvvv commentedNow when the dropdown menu is open, and ESC is pressed, the focus should return to the dropdown toggle, not to the body.
I have added an after-patch screen recording for the same.
Patch #6, fixed the issues.
Comment #8
andy-blumI can confirm the proper esc behavior occurs while signed out. +1 for RTBC.
Comment #9
lauriiiIt seems like the focus isn't working properly on mobile navigation. I think it would be useful to add tests for both, mobile and desktop use cases.
Comment #10
mherchelI'm still on the fence of this one.
In the summary, @bnjmnm added
However, in practice this is not the case. The body does receive the focus, but when the TAB key is pressed, the focus returns to the next element within the menu. This to me is a "meaningful movement of focus" and does not violate logical focus order.
I'm attaching a video.
Comment #11
bnjmnmThe next item in the menu is not immediately preceded by
bodyin the tabbing order, so this isn't a logical focus order.bodyreceiving focus is fallback behavior when the currently focused element becomes unavailable. A small change tocloseAllSubNavwould take care of this:Comment #12
mherchelI like your idea to add the functionality into the
closeAllSubNavbetter than my original implementation.Patch attached (with tests!)
Comment #13
mherchelGah. Forgot to run prettier. New patches attached.
Comment #14
bnjmnmThe selector needs to be a 'js-' prefixed class or data attribute to distinguish it from classes used for presentation purposes. Otherwise this won't pass the JavaScript selectors core gate. Also see #2431671: [meta] Add in js- prefixed classes for separation of JS & CSS functionality.
Comment #15
mherchelI'd honestly like to tackle that holistically in #3153234: [Meta] Olivero JavaScript should be selecting [data-drupal-selector] attributes where possible. There are a ton of selectors in that file that do not meet that criteria, and I don't think we should refactor them in this issue.
That issue is a stable blocker, so it'll get fixed, but IMO the changes are unrelated to this specific issue.
Comment #16
mitthukumawat commentedPatch #13 applied cleanly on drupal 9.3.x-dev version. Thanks for the patch.
Comment #17
andy-blumEscape key properly returns focus to the dropdown-toggling element on wide & mobile versions. Screen recordings attached, moving to RTBC.
Comment #18
lauriiiLet's expand the tests to include mobile menu too ✌️
Comment #19
mherchelDone. Patch attached.
Comment #20
mherchelHad some invalid comments in the tests from the code that I copied over. Removing these, and re-attaching patches.
Comment #21
mherchelTests are passing on my local, but failing on Drupal's CI.
The error that we're getting is
Comment #22
mherchel🤞
Comment #23
mherchel🤞🤞
Comment #24
mherchelYay! #23 is the winner!
Attached is a patch with the tests only, so we can see the failure.
Comment #25
rinku jacob 13 commentedpatch #23 successfully applied for 9.3.x-dev
Comment #26
andy-blumPatch applies and the functionality works, but tabbing through a long dropdown list doesn't automatically scroll the viewport as added in #3190120.
Looking at core's commit history, it looks like that fix was only added to 9.2.x and not the 9.3.x branch. If that's not a problem, then +1 for RTBC
Comment #27
guilhermevp commentedPatch works as intended. I believe that fix #3190120: Olivero: Focused level-2 nav items should always be in viewport during keyboard navigation. was commited to 9.3.x in
11af82aso I'm not sure if it should be considered RTBC as well.Comment #28
guilhermevp commentedOps, changed it by accident.
Comment #29
andy-blumDisregard #26. My local was behind, patch applies and works. Moving to RTBC
Comment #30
bnjmnmIn both tests, between the tab and escape presses, there should be confirmation that focus has moved. If keyboard navigation were somehow broken, this test would still pass as it's checking if the most recently clicked element has focus.
Comment #31
bnjmnmComment #32
mherchelPatches attached!
Comment #33
bnjmnmThat takes care of #30.
The code looks good & straightforward, and this works on manual review with both toggle buttons and links.
Comment #36
lauriiiCommitted 7d68989 and pushed to 9.3.x and 9.2.x. Thanks!