-
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
DropdownMenuV2: remove flashing styles when moving focus with keyboard #64873
Conversation
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. |
cc @diegohaz — do you have any insights on why this is happening, and if there is a better fix? |
Yes, |
Sure — here it is: ariakit/ariakit#4083 |
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.
Good one, @ciampo 👍 🚀
I'm assuming this will be useful regardless of a potential Ariakit fix. Should we add a note to check if we can clean it up in the future?
af10bc2
to
e03508b
Compare
WordPress#64873) * DropdownMenuV2: remove flashing styles when moving focus with keyboard * CHANGELOG * Add comment about ariakit issue --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: diegohaz <hazdiego@git.wordpress.org>
What?
Part of #50459
Removing "flash of unwanted styles" when navigating
DropdownMenuV2
items using the keyboard.Why?
While working on
DropdownMenuV2
, I noticed that menu items would sometimes flash briefly with the "active (hover)" styles, before applying the expected "focus-visible" styles — ie. it seems that the underlying ariakit implementation doesn't apply thedata-focus-visible
attribute soon enough, and therefore the focus-visible styles are applied with a delay, causing the hover (active) styles to apply for a few frames.How?
I removed the flash by using the native
:focus-visible
CSS selector, which matches without any delays.Testing Instructions
In Storybook, interact with the DropdownMenuV2 examples using keyboard, moving across the menu items.
On trunk, you could sometimes see the aforementioned flash — with the changes from this PR, the flash should never happen.
Screenshots or screencast
ddmv2.flash.before.mp4
ddmv2.flash.after.mp4