-
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 flickering when focusing on global style variations #55267
Conversation
Size Change: +22 B (0%) Total Size: 1.65 MB
ℹ️ View Unchanged
|
border: $gray-200 $border-width solid; | ||
box-shadow: 0 0 0 $border-width $gray-200; | ||
// Shown in Windows 10 high contrast mode. | ||
outline: 1px solid transparent; |
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.
Nitpick we have this for other high contrast mode contexts:
// Windows high contrast mode.
outline: 2px solid transparent;
Completely separate, I wonder if we should create a mixin for this, then the mixin can contain the named context so we don't need a CSS comment, and it can be consistent across.
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.
Works for me!
Thanks for the review, @jasmussen!
I certainly think that makes sense. There are some variations of |
I just cherry-picked this PR to the 6.4-rc1-2 branch to get it included in the next release: cf63b7d |
* Add selector as id to layout style overrides. (#55291) * Fix flickering when focusing on global style variations (#55267) * ProgressBar: use text color to ensure enough contrast against background (#55285) * Use text color at different opacities for track and indicator * Add high contrast mode styles * CHANGELOG # Conflicts: # packages/components/CHANGELOG.md * Remove empty attrs. (#54496) * Remove empty attrs. * Fix linter errors --------- Co-authored-by: Sarah Norris <sarah@sekai.co.uk> * Add IS_GUTENBERG_PLUGIN flag to LastRevision (#55253) * useBlockPreview: Try outputting EditorStyles to ensure local style overrides are rendered (#55288) * useBlockPreview: Try alternative fix for displaying local style overrides * Avoid duplicate styles, fix rendering issues in Safari * Add more explanatory comments * Remove additional check for styles within the block preview, as it is not needed since EditorStyles handles its own style overrides retrieval * Bug: PHP notice when an image with lightbox is deleted (#55370) * Fix PHP notice when an image with lightbox is deleted * Fix PHP notice when an image with lightbox is deleted --------- Co-authored-by: tellthemachines <tellthemachines@users.noreply.github.com> Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com> Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com> Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Co-authored-by: Kishan Jasani <kishanjasani007@yahoo.in>
What?
This PR prevents flickering that occurs when focusing on global style variations.
At the same time, it improves visibility in Windows high contrast mode, as explained later.
Before
before.mp4
After
after.mp4
Why?
Global style variations have the following four states.
As you can see, only the focus style has a thick border, so flickering occurs when the size of the element changes.
How?
I used
box-shadow
instead ofborder
so that it doesn't affect the size of the elements.Windows High Contrast Mode
In Windows high contrast mode, all borders have the same color. Because the default variation and the selected variation had the same 1px wide border, users using high contrast mode had no way of knowing which style variation was active. Also, it was impossible to determine which variation was focused or not based on just a 1px difference in the border.
In this PR, borders are replaced with box-shadow, so they are not displayed at all in high contrast mode. Instead, use transparent outlines, similar to the approach Gutenberg has traditionally taken.
In order to make it easier to understand the minimum required state, I have adjusted it so that it looks like the following.
high-contrast-after.mp4
Testing Instructions
In the following two places, confirm that the appearance is as expected no matter what operation you perform, and that flickering does not occur when you shift focus using the keyboard.