-
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
fix change focus
to focus-visible
in navigation block css
#60429
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: +10 B (0%) Total Size: 1.73 MB
ℹ️ View Unchanged
|
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.
@fabiankaegy thanks for your ping to ask for a review.
I'm not sure we should change this so lightly.
- I'd think this would need a broader consideration as in: either WordPress should always uss
focus-visible
on the front end or it should not. I'm not sure using it only for the navigation overlay initial focus would be ideal. Instead, it should be consistent for all focus styles. - Personally, I don't like
focus-visible
that much because it makes an assumption and then delegates to browser internal heuristics to determine when a pointing device or other devices are in use. The assumption is that users are either using the mouse or the keyboard. That's often a wrong assumption, as many useers do use a mix of devices. Personally, I use both mouse and keyboard often during the same flow.
Anyways, this change will not work for all themes. For xample, Twenty Twenty-Four sets a global style from its theme.json
that has a higher specificity so that hte focus style is visible also when using the mouse:
:where(.wp-site-blocks *:focus){outline-width:2px;outline-style:solid}
I'd like to see this change be considered in a broader discussion. Could you please createa GitHub issue to allow for a broader discussion?
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
To clarify the intent of this change, it would make the focus style of the first item in the menu overlay (when a navigation block is set to use an overlay) not visible when using the mouse: and still visible when using the keyboard: To test this with Twenty Twenty-Four, the custom style set by the theme in Styles > Additional CSS needs to be removed: clear the textarea and save. Cc @joedolson |
@afercia Thanks for the thorough review :) From my perspective, I think I only partially agree with the fact that this should be a more holistic topic we discuss. To me there is a massive difference between a theme making a visual choice for how it wants to style its content vs. how the core navigation block styles its focus states by default. So I don't think making this change here wouldn't have to mean anything for the tt4 theme or any other theme in the theme directory. To me this is an area where this PR attempts to make the default behavior of the core block less opinionated to leave it up to themes how they want to style it. |
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.
Thanks for proposing this enhancement @fabiankaegy 👍
To me this is an area where this PR attempts to make the default behavior of the core block less opinionated to leave it up to themes how they want to style it.
I like the intent of this PR but I do think we might need to take a moment as @afercia suggests to consider a few things more broadly.
As part of the consistency angle to this, theme.json only supports the :focus
pseudo selector and not :focus-visible
. To me, it would make sense that our default styles and those supported via theme.json are consistent.
@aaronrobertshaw that is a very good point I hadn't considered :) makes sense to me 👍 |
@fabiankaegy Yes, personally I'm a little concerned about it as well. I'm really not sure the editor should provide its own custom focus styles for the front end. From an accessibility perspective, when it comes to focus style the best option is to just do nothing and let browsers do their job. I know contributors to this project have different opinions about what is responsibility of the editor and what is responsibility of themes. However, what I would really like to avoid is that the editor ends up using I would also like to remind everyone that the contributing guidelines of this project ask to create an issue for any non-trivial change to allow for broader discussion. That is not different from the process WordPress alwayse used on Trac. For a collaborative open source project, broader discussion is of fundamental importance. Alas, in this project I've seen many, too many, pull requests without an associated issue.
|
What?
Changes the styling of the Navigation block to use the
focus-visible
selector instead of thefocus
selectorWhy?
When the navigation overlay opens the first item receives focus. As it should. However it is confusing to users why the element looks different than all the other elements.
focus-visible
is meant for this exact purpose. To style elements when they receive focus through the keyboard etc.How?
changing the instances of
focus
tofocus-visible
Testing Instructions
Ensure the navigation block still has proper focus states
Testing Instructions for Keyboard
Screenshots or screencast