-
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
Add missing focus style to start template options previews. #49334
Add missing focus style to start template options previews. #49334
Conversation
Size Change: +6.1 kB (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Flaky tests detected in c04f645. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4629535194
|
Thank you for the PR! This component ( How about the following change to take advantage of the defined pseudo-class? diff --git a/packages/edit-site/src/components/start-template-options/style.scss b/packages/edit-site/src/components/start-template-options/style.scss
index ca086ef085..d19ffad9d0 100644
--- a/packages/edit-site/src/components/start-template-options/style.scss
+++ b/packages/edit-site/src/components/start-template-options/style.scss
@@ -25,9 +25,12 @@
width: 100%;
aspect-ratio: 3/4;
+ &:not(:focus):not(:hover) {
+ box-shadow: 0 0 0 1px $gray-300;
+ }
+
.block-editor-block-preview__container {
height: 100%;
- box-shadow: 0 0 0 1px $gray-300;
}
.block-editor-block-preview__content {
@@ -38,21 +41,6 @@
.block-editor-block-patterns-list__item-title {
display: none;
}
-
- &:hover {
- .block-editor-block-preview__container {
- box-shadow: 0 0 0 2px var(--wp-admin-theme-color);
- }
- }
-
- &:focus {
- .block-editor-block-preview__container {
- box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-the
me-color);
-
- // Windows High Contrast mode will show this outline, but not the box-shadow.
- outline: 2px solid transparent;
- }
- }
}
// The start blank pattern is the last and we are selecting it. |
@t-hamano good catch, thanks. More red in a PR's diff is always better ❤️ |
Sorry, there was an error in the code I presented. The default gray box-shadow should be applied to diff --git a/packages/edit-site/src/components/start-template-options/style.scss b/packages/edit-site/src/components/start-template-options/style.scss
index 13f4d960d9..092251a81b 100644
--- a/packages/edit-site/src/components/start-template-options/style.scss
+++ b/packages/edit-site/src/components/start-template-options/style.scss
@@ -26,16 +26,16 @@
width: 100%;
aspect-ratio: 3/4;
+ .block-editor-block-preview__container {
+ height: 100%;
+ }
+
// Avoid to override the BlockPatternList component
// default hover and focus styles.
- &:not(:focus):not(:hover) {
+ &:not(:focus):not(:hover) .block-editor-block-preview__container {
box-shadow: 0 0 0 1px $gray-300;
}
- .block-editor-block-preview__container {
- height: 100%;
- }
-
.block-editor-block-preview__content {
width: 100%;
position: absolute; This change would make the rounded corners uniform regardless of the focus state. BeforeAfter |
@t-hamano good catch, thanks. That would trigger again the missing focus style though. I think the fix needs to be slightly different, as the actual focusable element is the children: Should be fixed in my last commit. |
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.
LGTM! It is working as expected.
I think the fix needs to be slightly different, as the actual focusable element is the children:
That makes sense 👍
Fixes #49333
What?
Adds missing focus style to the patterns preview in the 'Choose a pattern' modal.
Why?
Any interactive element must have a focus style.
How?
Uses the right CSS selector.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast