-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor: when Toggle navigation receives state false, focus #37265
Editor: when Toggle navigation receives state false, focus #37265
Conversation
…rigger for screen readers.
useEffect( () => { | ||
// Focus the trigger button if close | ||
if ( ! isNavigationOpen ) { | ||
navigationToggleRef.current.focus(); | ||
} | ||
}, [ isNavigationOpen ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making this PR! However, I don't think this is the right solution. We don't want to focus the button whenever it gets closed, we only want to focus it whenever route changes. This could have some unwanted side-effects (for instance, if we want to close this one to open another sidebar, the focus could be moved to this button). I opened #37314 for an alternative approach which I believe could be more robust, but also requires a lot of changes 😅 .
@kevin940726 Think you'll be able to land your PR for 5.9 beta? Concept seems simple enough but that is a ton of changed files. I know my solution is subjective at best but do you think it's worth keeping this open in case your PR doesn't make beta in time? One way or another, this issue with focus has to be managed. Your way sounds a lot more full proof though so if that lands, let's go for it. |
@alexstine I 100% agree. It's essentially what I wrote in the PR description too! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevin940726 Sounds good. |
There's a conflict in the file, let's rebase and fix it. And maybe add the |
packages/edit-site/src/components/navigation-sidebar/navigation-toggle/index.js
Outdated
Show resolved
Hide resolved
Co-authored-by: George Mamadashvili <[email protected]>
@kevin940726 Committed @Mamaduka changes. Hopefully this should be good to go now. 👍 Thanks to you both for working on this. |
* Site Editor: when Toggle navigation receives state false, focus the trigger for screen readers. * Add comment that points to a future PR Co-authored-by: George Mamadashvili <[email protected]> Co-authored-by: George Mamadashvili <[email protected]>
Description
In the Site Editor, Toggle navigation button will have focus placed on the trigger when open state changes to false. This is so when screen reader/keyboard users select an item from the menu, they are dropped back at a global point "Toggle navigation" which is the first element on the page.
Follow up to: #36597
How has this been tested?
I tested in Firefox with NVDA screen reader on Windows 10.
To test:
Screenshots
Types of changes
Bug fix.
Checklist:
*.native.js
files for terms that need renaming or removal).