Skip to content
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

ItemGroup: Update button focus styles to be more consistent #51576

Merged
merged 4 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Enhancements

- `Modal`: Update corner radius to be between buttons and the site view frame, in a 2-4-8 system. ([#51254](https://github.com/WordPress/gutenberg/pull/51254)).
- `ItemGroup`: Update button focus state styles to be inline with other button focus states in the editor. ([#51576](https://github.com/WordPress/gutenberg/pull/51576)).

### Bug Fix

Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/item-group/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ export const unstyledButton = css`
&:hover {
color: ${ COLORS.ui.theme };
}

&:focus {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered using :focus-visible instead, so that the focus ring only shows when interacting with the keyboard?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, actually I initially was going to use :focus-visible, but it looks like the other buttons in the editor mostly use :focus. This doesn't mean it's the best way, but I was mainly trying to keep the styling consistent between the other editor buttons. Maybe all the buttons could be updated to use :focus-visible?

Copy link
Contributor

@ciampo ciampo Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could be something to keep in mind, yes. Let's wait for Joen's feedback , in case 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for the ping! Just for clarity, here's before:

before 1

before 2

Here's after:

after 1

after 2

In the after state, the focus style is now the correct color and the correct width (1.5px) in both places. However to Marco's point, it also now adds sticks the focus style when mouse navigating, which is especially jarring in these drilldown situations. I'd lean towards using focus visible here, it's already being applied for the back button in the site view, despite that lingering tooltip.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks both! I agree that :focus-visible makes more sense here, I've opened up a small follow-up PR: #51787

box-shadow: 0 0 0 var( --wp-admin-border-width-focus )
mikachan marked this conversation as resolved.
Show resolved Hide resolved
var(
--wp-components-color-accent,
var( --wp-admin-theme-color, ${ COLORS.ui.theme } )
);
// Windows high contrast mode.
outline: 2px solid transparent;
}
`;

export const itemWrapper = css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,14 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
}
.emotion-13:focus {
box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) var(
--wp-components-color-accent,
var( --wp-admin-theme-color, var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)) )
);
outline: 2px solid transparent;
}
.emotion-15 {
display: -webkit-box;
display: -webkit-flex;
Expand Down
Loading