Repository navigation
Toolbar: Keep the pressed and focus indicator square - #86855
Conversation
The 1px transparent border reserved on every Button shrank the toolbar button's ::before (which paints the pressed background and the focus ring) from 32x32 to 30x32, because absolutely positioned offsets are measured from the padding box. Subtract the border width from the left/right offsets so the indicator is square again. Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +55 B (0%) Total Size: 8.66 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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. should apply a named font size using the font size buttons in
|
The ::before height of the vertical mover buttons is measured from the padding box, so the 1px reserved Button border shrank it from 16px to 14px. Add the border back. Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST
The mover buttons clip their overflow, so enlarging their ::before cuts off the focus ring. Revert the height change and keep the original 2px inset instead of following the toolbar group's offsets. Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST
| // Keep the focus ring inset enough to stay visible instead of following | ||
| // the toolbar group's offsets. Matches the toolbar group's specificity. | ||
| &.has-icon.has-icon::before { | ||
| left: 2px; | ||
| right: 2px; | ||
| } |
There was a problem hiding this comment.
This override is needed because the block mover buttons clip their overflow. overflow: hidden was added in #67261 to prevent misclicks.
Without this override, the focus ring sits too close to the button's edge, so its sides and rounded corners get clipped.
Co-authored-by: Lena Morita <lena@jaguchi.com>
* Toolbar: Keep the pressed and focus indicator square The 1px transparent border reserved on every Button shrank the toolbar button's ::before (which paints the pressed background and the focus ring) from 32x32 to 30x32, because absolutely positioned offsets are measured from the padding box. Subtract the border width from the left/right offsets so the indicator is square again. Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST * Add changelog entry Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST * Block Mover: Keep the vertical focus indicator height The ::before height of the vertical mover buttons is measured from the padding box, so the 1px reserved Button border shrank it from 16px to 14px. Add the border back. Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST * Block Mover: Keep the focus ring visible inside clipped buttons The mover buttons clip their overflow, so enlarging their ::before cuts off the focus ring. Revert the height change and keep the original 2px inset instead of following the toolbar group's offsets. Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST * Nest the block mover focus ring offsets into the button rule Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URw1rqvJyd3rrDFo5ST * Update changelog entry Co-authored-by: Lena Morita <lena@jaguchi.com> --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
What?
Restores the 32x32 square for the pressed background and focus ring of toolbar buttons, which are currently 30x32.
Why?
#79982 improved the secondary variant of
Buttonby drawing its outline with a real border, and reserved a 1px transparent border on every variant so that all variants share the same box size. To keep small icon buttons square despite this border, it also applied a negative inline margin to the icon (see #79982 (comment) for details).As a side effect, the padding box of every button became 2px narrower. The negative margin restores the button's own width, but not the
::beforeof toolbar buttons: itsleft/rightoffsets are measured from the padding box, so the pressed background and focus ring of toolbar buttons shrank from 32x32 to 30x32.This only happens in the toolbar: a regular
Buttondraws its focus ring with an outline on the element itself, while toolbar buttons draw the pressed background and focus ring on an absolutely positioned::before, whose size depends on the padding box.How?
Subtract
$border-widthfrom the::beforeoffsets where they are defined, inToolbar/ToolbarGroup. The fix belongs there because the toolbar owns this::beforetreatment.Ideally, the toolbar would use the design system's outline-based focus ring like other buttons, and this problem would not exist in the first place. However, the toolbar's button styles are heavily customized, so that is not something we can do right now.
Testing Instructions
::beforeis 32x32.Testing Instructions for Keyboard
Use of AI Tools
This PR was investigated and authored with Claude Code, and reviewed by me.