Opened 6 weeks ago
Last modified 5 weeks ago
#66247 new defect (bug)
Admin: Button styles are not consistent in active-while-focused states
| Reported by: | aduth | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | ui, accessibility, css |
Description
r46241 (#34904) added styles which remove the focus ring while a button is active by assigning box-shadow: none to .button:active. This effect can be seen when activating buttons like "Search Posts" on the Posts screen.
Bug: Not all buttons apply this consistently, for example the "Save Changes" button on the Settings > General screen maintains the focus ring while active.
Technical Analysis:
Secondary buttons and buttons forced active with the .active class hide the focus ring, while plain (primary) buttons and tertiary buttons have no corresponding style. These styles are used in generating color scheme stylesheets that are loaded after the base styles from buttons.css, and take priority over the base styles.
Resolution:
Adding box-shadow: none consistently to all of the button mixins would likely be the expected resolution given the current state of button styling.
In parallel, Gutenberg's GB#84090 discusses general styling updates for this state which may ultimately make current assumptions obsolete, but does not block consistency improvements in the meantime.
Attachments (5)
Change History (9)
This ticket was mentioned in Slack in #accessibility by aduth. View the logs.
6 weeks ago
#3
@
5 weeks ago
Test Report
Description
This report validates whether the indicated patch works as expected.
Patch tested: 66247.diff
Environment
- WordPress: 7.2-alpha-63166-src (trunk b1bfeaf)
- PHP: 8.3.35
- Server: wordpress-develop Docker environment
- Browser: Chromium (Playwright)
- OS: macOS
- Theme: Twenty Twenty-Five
- Plugins: none
- Admin color schemes: Default (modern), Fresh, Midnight, Light
Steps taken
- Opened Settings > General ("Save Changes", primary) and Posts ("Search Posts", secondary).
- Pressed and held each button with the mouse, and with the Space key after focusing it.
- Recorded the computed
box-shadowwhile the button matched:active. - Repeated with the
.activeclass added to each button. - Applied the patch, ran
grunt colors, and repeated steps 1-4.
Actual Results
Before the patch, the primary and secondary buttons behave differently in every scheme except Fresh:
- Primary, active while focused: the focus ring stays.
- Secondary, active while focused:
box-shadow: none, so the focus ring disappears.
In Fresh, both buttons lose the ring, because Fresh has no color scheme stylesheet and only uses buttons.css, where .button:active and .button-primary:active both set box-shadow: none.
With the patch, the secondary button keeps its focus ring while active, the same as the primary button. Results are the same with the mouse and with the keyboard:
| Scheme | Primary :active | Secondary :active (before) | Secondary :active (after) |
|---|---|---|---|
| Default (modern) | ring | none | ring |
| Midnight | ring | none | ring |
| Light | ring | none | ring |
| Fresh | none | none | none (unchanged) |
✅ The patch makes primary and secondary buttons consistent in the color schemes that use _mixins.scss.
Additional Notes
- The patch goes the opposite way from the resolution in the description, and I think the patch is the right direction. In the Default (modern) scheme, the primary button already keeps its focus ring while active. The patch makes the secondary button match that. Adding
box-shadow: noneto every mixin would instead remove the ring that Default's primary button shows today. - The patch does not change Fresh, because Fresh does not load the color scheme stylesheet.
- The
button-tertiary()mixin is not included anywhere in_admin.scss, so it does not affect any rendered button today.
Supplemental Artifacts
Before, Default scheme, buttons held down (Search Posts loses the ring): https://drive.google.com/file/d/1rI0uWZti8mKr3r6fupccNHxKkKmw81cf/view?usp=drive_link
After (both buttons keep the ring): https://drive.google.com/file/d/1F55R6GZdBrQ1_FSNR1Tn31kT03aKyfCP/view?usp=drive_link
This ticket was mentioned in PR #14235 on WordPress/wordpress-develop by @wprashed.
5 weeks ago
#4
---
Description
In r46241 (#34904), styles were added to remove the focus ring while a button is active by assigning box-shadow: none to .button:active.
However, the admin color scheme stylesheets generate button styles via mixins in _mixins.scss. While button-secondary() and .active classes explicitly specify box-shadow: none, the button() (primary) and button-tertiary() mixins omitted this property on &:active. As a result, primary buttons (such as "Save Changes" on Settings screens) and tertiary buttons maintained their focus ring while active when a color scheme was loaded.
Solution
Add box-shadow: none; to the &:active pseudo-class in the button() and button-tertiary() mixins in src/wp-admin/css/colors/_mixins.scss, making the active-while-focused button behavior consistent across all button variants.
How to test
- Go to Settings > General (or any screen with a primary button like "Save Changes").
- Focus the "Save Changes" button using Tab or mouse click.
- Press and hold the button (or spacebar/mouse down). Verify that the focus ring outline/shadow disappears while active, matching the behavior of secondary buttons (e.g., "Search Posts" or "Reset").
The fix 66247