Skip to content

Editor: Fix regression and restore the back button focus ring#80029

Merged
fushar merged 2 commits into
trunkfrom
fix-back-button-focus
Jul 9, 2026
Merged

Editor: Fix regression and restore the back button focus ring#80029
fushar merged 2 commits into
trunkfrom
fix-back-button-focus

Conversation

@fushar

@fushar fushar commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What?

Fixes a "regression" introduced by #79837.

The sidebar back button in the Site Editor (.edit-site-sidebar-button) is overriding the default focus styles. It now conflicts with the linked PR because that added this rule:

&:is(a) {
      box-shadow: none;
}

The correct fix here is to just follow what WP DS provides for the focus ring styles, so this PR removes the overrides.

However, it means that the focus ring color for the sidebar menu items (like Navigation, Pages, Templates) will be different from the back button. In this PR, we "fix" it by overriding it locally. The proper fix is to update the <Item> component so that it uses WP DS styles, as done in #78646. I left a // TODO comment on that.

Testing Instructions

  1. Go to Site Editor (Appearance -> Editor)
  2. Use the tab key to try to focus to the < back button in < Design
  3. Verify you can see the focus state again.
  4. Verify the focus state for all sidebar items are consistent with the <.

Screenshots or screencast

Before After
image image

Use of AI Tools

Used Opus 4.8 to investigate the issue.

@github-actions github-actions Bot added the [Package] Edit Site /packages/edit-site label Jul 9, 2026
@fushar fushar added the [Type] Bug An existing feature does not function as intended label Jul 9, 2026
@fushar fushar requested review from a team and t-hamano July 9, 2026 03:39
@fushar fushar marked this pull request as ready for review July 9, 2026 03:40
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: fushar <fushar@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Size Change: -79 B (0%)

Total Size: 7.68 MB

📦 View Changed
Filename Size Change
build/styles/edit-site/style-rtl.css 21.5 kB -20 B (-0.09%)
build/styles/edit-site/style-rtl.min.css 17.6 kB -20 B (-0.11%)
build/styles/edit-site/style.css 21.5 kB -19 B (-0.09%)
build/styles/edit-site/style.min.css 17.6 kB -20 B (-0.11%)

compressed-size-action

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Flaky tests detected in bf58e9c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29000155915
📝 Reported issues:

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given the stronger push for design system adherence now, it might be a good time to remove any ad hoc focus-visibles and see what happens, especially in places like this where it isn't that critical.

Comment on lines +28 to +36
&:focus-visible {
transform: translateZ(0);
// TODO: remove once the <Item> component has migrated to the
// design-system focus ring (`outset-ring__focus`), as <Button> did in #78646.
//
// This override is necessary now so the focus ring matches with
// the editor back button.
box-shadow: none;
@include mixins.outset-ring__focus();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Possibly cleaner/safer in the short term?

Suggested change
&:focus-visible {
transform: translateZ(0);
// TODO: remove once the <Item> component has migrated to the
// design-system focus ring (`outset-ring__focus`), as <Button> did in #78646.
//
// This override is necessary now so the focus ring matches with
// the editor back button.
box-shadow: none;
@include mixins.outset-ring__focus();
&:focus-visible {
// TODO: remove once the <Item> component has migrated to the WPDS focus color token.
--wp-components-color-accent: var(--wpds-color-stroke-focus);
transform: translateZ(0);

Comment on lines -5 to -16
// Focus (resets default button focus and use focus-visible).
&:focus:not(:disabled) {
box-shadow: none;
outline: none;
}
&:focus-visible:not(:disabled) {
box-shadow:
0 0 0 var(--wp-admin-border-width-focus)
var(--wp-admin-theme-color);
outline: 3px solid transparent;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I personally am fine with removing the override, but I'll note that the switch to focus-visible was done intentionally in #48472. (And in case anyone is curious why focus-visible isn't the global default, see #65088 where we reached an agreement that we shouldn't.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the context!

the switch to focus-visible was done intentionally in #48472

I checked and it looks like this PR does not re-introduce the "bug" that the PR was fixing. The behavior is similar to the editor in GB 23.5. So it seems it's fine to keep this removal. (And I agree with your point that we should push for the built-in DS stylings).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I checked and it looks like this PR does not re-introduce the "bug" that the PR was fixing. The behavior is similar to the editor in GB 23.5.

I'm really sorry, I misunderstood that PR! I agree with the PR that showing focus ring on back button during navigation is distracting. Fixing here: #80114

Comment on lines +30 to +31
// TODO: remove once the <Item> component has migrated to the
// design-system focus ring (`outset-ring__focus`), as <Button> did in #78646.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for reporting this 🙏

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice catch!

Comment on lines +30 to +36
// TODO: remove once the <Item> component has migrated to the
// design-system focus ring (`outset-ring__focus`), as <Button> did in #78646.
//
// This override is necessary now so the focus ring matches with
// the editor back button.
box-shadow: none;
@include mixins.outset-ring__focus();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

However, it means that the focus ring color for the sidebar menu items (like Navigation, Pages, Templates) will be different from the back button. In this PR, we "fix" it by overriding it locally.

I think this seems like an issue that should be addressed separately from this PR, as the color mismatch is already occurring in trunk.

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I think you're right. It seems it's better to "fix" this at the source instead of adding more chaos to the CSS 😅 reverted for now!

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@fushar fushar merged commit 749d10a into trunk Jul 9, 2026
44 of 45 checks passed
@fushar fushar deleted the fix-back-button-focus branch July 9, 2026 08:17
@github-actions github-actions Bot added this to the Gutenberg 23.6 milestone Jul 9, 2026
scruffian pushed a commit that referenced this pull request Jul 10, 2026
Co-authored-by: fushar <fushar@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Edit Site /packages/edit-site [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants