-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Navigator: focus screen wrapper instead of first tabbable element #51816
Conversation
cc @alexstine to make sure that these changes don't cause any regression for assistive technology |
Flaky tests detected in 993123732745a2a34f4d0a95de128ab19c32e0ce. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5349395898
|
@ciampo Thanks for the ping. This isn't going to work because this type of focus behaver is what I would expect from an application that totally has a loss of all focus when switching in between contexts. The thing you must remember with React is everything needs a stable focus point especially in the case of the site editor with the virtual rendering/routing. You will need to find another solution for the visual UX issues as this introduces an accessibility disparity far too large. I suspect this likely fails WCAG AA as well considering there would be no focus outline on the wrapping This PR is a no-go. Thanks. |
I would consider this an accessibility regression; it adds extra steps for screen reader and keyboard navigation unnecessarily. Without testing, I'm not sure what the aural feedback will be like when landing on the screen wrapper; but I expect it would be quite verbose and potentially very confusing. It seems like the reason for this is to prevent a tooltip from appearing when a control receives focus, but to me I'd consider that a reasonable and expected behavior that's very helpful for sighted keyboard navigators to quickly identify their location on the page. |
@alexstine I'm not sure you've understood what this PR is proposing — focus wouldn't be moved to the
The To give you a concrete example, the global styles sidebar is implemented with
As explained above, the "first tabbable element of the screen would always be the next tab stop. To be honest, I believe this replicates more closely the expectations of our users. When navigating to a new URL, browsers don't focus the first tabbable element either. With these changes, when the user navigates to a new In my opinion, for a user of assistive technology, navigating the contents of a new screen starting from its wrapper sounds like a better and more reliable way than starting from whichever first tabbable element, since that element could be anywhere in the screen. Would adding an It is also worth noting that the component would still retain its focus restoration behaviour when navigating back to a screen visited previously, restoring focus on the element that was clicked to generate the navigation.
That was definitely one of the triggers for this change, although I'd say not the main reason. As mentioned above, the current behavior of moving focus programmatically to a new tabbable element can feel very disorienting to a user ("I clicked a button, why is this other button is focused ??"), regardless of whether they are relying on sight or using assistive technology. |
This could be a better approach rather then hiding the tooltip. Tooltips are required for icon buttons, as the accessible name of a control must always be exposed in some way. Te Back button tooltip was already fixed in #49657 / #49659 and then hidden again in #51725. That's a regression I'd love to see fixed for WP 6.3. I'll take some time to have a look at this PR as soon as I find some time ❤️ |
|
||
&:focus { | ||
outline: none; | ||
} |
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.
Focus indication must always be visible. Instead of resetting native outline, we should provide our own custom focus style.
@@ -211,6 +211,7 @@ function UnconnectedNavigatorScreen( | |||
<motion.div | |||
ref={ mergedWrapperRef } | |||
className={ classes } | |||
tabIndex={ -1 } |
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.
Setting focus on an element with no ARIA role and no label is less than ideal. Although I do see aria-labels in the test, I don't see actual aria-label attributes set in the DOM.
The element that receives focus also needs an ARIA role.
Looked a bit into this and definitely thinking it's a better approach than focusing the first tabbable which becomes prolematic when the first tabbable is an icon button. There are a few things to improve though:
Lastly, we should make sure this works and makes sense also in other spots where the Navigator is sued, for example in the Styles. |
For completeness, worth mentioning a way simpler solution would be to not use an icon button in the first place 😄 Buttons with visible text are way more accessible and usable for all users and... they don't need a tooltip 🎉 Back buttons with icon + text are not new in the editor, although there's some inconsistency across al these Back buttons, see #50106 |
@ciampo Is it possible I found an unrelated bug then?
Did I test the wrong thing all together or did this PR cause an additional regression? Tested with Firefox on Windows. Thanks. |
9931237
to
89c0286
Compare
Just pushed a few updates following @afercia's feedback. Here's how the site editor's sidebar would look like now: navigator-screen-wrapper-focus.mp4
I've added some initial styles to highlight when the screen wrapper received focus, although I didn't spend too long to refine them since I'm sure that @jasmussen will have some feedback to share.
This PR focuses on the
Thank you for the remainder. This would definitely be the simpler solution to avoid tooltips showing when focusing the back buttons (cc @jasmussen)
I have tested both
Maybe @afercia can help to reproduce this bug, in case I'm missing something? |
…gator-focus-screen
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.
@ciampo Just gave this another test on Windows using Firefox.
- Open the site editor.
- Select Templates button.
- Focus loss occurs.
<body class="wp-admin wp-core-ui js i…support sticky-menu svg">
I just refreshed the branch as it was pretty far behind and not testable locally.
This just isn't working for me. 😞
Closing as stale. We can re-open / try a different approach in the future if necessay. |
What?
This PR tweaks the way
Navigator
manages focus when navigating to a new screen.Why?
As discussed in #51762, the current focus restoration behavior of the
Navigator
component can cause some unexpected consequences depending on what component gets programmatically focused when navigating to a new screen.For wider context: #51762 (comment)
How?
Prior to this PR, when navigating to a new screen,
Navigator
moves focus to either:The changes from this PR cause the "fallback" focus behavior to focus on the navigator screen wrapper, instead of the first focusable item.
Testing Instructions
In the storybook's Navigator example:
In the side editor's sidebar:
Screenshots or screencast
Trunk:
navigator-edit-site-trunk.mp4
This PR:
navigator-edit-site-this-pr.mp4