-
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
Fix the navigate regions focus style #45369
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: +1 kB (0%) Total Size: 1.29 MB
ℹ️ View Unchanged
|
5b0b682
to
9f525f2
Compare
Rebased on latest trunk after changes for the new theming accent color, see #45289 |
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.
Code looks good to me, and it fixes the focus issue 👍
tabIndex="-1" | ||
{ ...motionProps } | ||
> | ||
<div className="interface-navigable-region__stacker"> |
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.
Noting that this may have caused a regression: #45778
A fix could be to set the display + flex direction on this __stacker
class, but I'm not familiar enough with the change to be sure.
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.
I can confirm this. The same is visible in the post editor if a theme has a non-white background.
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.
Looking into this!
@@ -0,0 +1,38 @@ | |||
# NavigableRegion |
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.
I wonder if this should be moved to the components package insect it's meant to be used in conjunction with useNavigateRegions from that package.
*/ | ||
import { withPluginContext } from '@wordpress/plugins'; | ||
|
||
export default withPluginContext( ( context, ownProps ) => { |
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.
Fixes #21717
What?
When navigating through the editor regions via the dedicated keyboard shortcuts, the focused region should show a blue outline as focus indicator. This used to work well in #8554 but it's broken since at least 2 years and a half, see #21717
It appears that new layouts and features introduced over time didn't take into consideration the navigable regions need to have a focus style. There are two main issues that make the focus style not visible:
Screenshot to illustrate the z-index issue:
Screenshot to illustrate the 0 size issue (this is the Publish panel toggle button, see there's no focus style on its wrapper region):
The original purpose of these regions is to allow keyboard navigation through the main parts of the editor and show a focus style. They're now also used for layout purposes, as parts of the 'interface skeleton', which is fine. However, it's very important to keep in mind that:
Why?
A clear focus indicator is a basic accessibility requirement for all sighted keyboard users, as they need to see where focus is.
How?
navigateRegions
CSS as we don't need a fix for IE11 any longer. Note: we can't use a CSS pseudo element as suggested in Regression: the navigate region focus style is broken #21717 because the pseudo element would scroll together wit the content.NavigableRegion
component to abstract the markup and features of the ARIA regions.NavigableRegion
renders the focusable ARIA landmark region and a child container.z-index: -1
so that any content within the region is positioned in the Z-axis at a lower level than the wrapper.navigateRegions
stylesheet.Testing Instructions
Screenshots or screencast
Animated GIF to illustrates the navigate regions focus style in action in the Post editor.