Repository navigation
UI Button: Show pressed state in forced colors mode - #85948
Conversation
Pressed neutral minimal buttons rely on a strong background color, which forced colors mode discards, leaving them identical to unpressed ones. Fill them with SelectedItem and SelectedItemText, or GrayText when disabled.
🤖 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: +609 B (+0.01%) Total Size: 8.61 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. Actions are reachable via RIGHT/LEFT arrow keys in
|
|
Can we revert individual fixes like #85904 once this is merged? |
I'm afraid not, those are still a custom case. |
# Conflicts: # packages/ui/CHANGELOG.md
|
This is marked for backport as fixing a bug, but the testing instructions apply to Storybook and I didn't observe any change in styles for the style variation buttons as shown in the sidebar screenshot. Is there a way to demonstrate the fix in the app? |
aduth
left a comment
There was a problem hiding this comment.
I verified that there was previously no discernible difference when toggling aria-pressed for a neutral, minimal button under forced colors, and that with these changes the state change is more clear when either pressed or pressed and disabled.
Looks like I need to fix that ad hoc. I'll remove the backport label for this one (it doesn't fix any live issue on its own), and do a separate fix for that. Thanks for catching. |
# Conflicts: # packages/ui/CHANGELOG.md
What?
Makes the pressed state of
Button(neutral tone, minimal variant,aria-pressed="true") visible in forced colors mode.Why?
The pressed state is conveyed only by a strong background and foreground color. Forced colors mode replaces both with system colors, so a pressed toggle looks the same as an unpressed one, and a disabled pressed toggle looks the same as a disabled unpressed one.
This is already affecting the app, for example these style variation buttons:
How?
Pressed buttons are filled with the system
SelectedItemandSelectedItemTextcolors and keep the unpressedButtonBorderborder, which keeps the filled look the pressed state has outside forced colors mode and matches howComboboxitems show selection in forced colors. A thicker border or an underline would also mark the state, but they are weaker cues and add shapes the button does not use elsewhere.Testing Instructions
active.aria-pressedoff in Controls and confirm the button returns to the outlined look.disabledin Controls and confirm the pressed button is filled with the gray disabled color and its label is readable.Testing Instructions for Keyboard
Screenshots or screencast
Unpressed, pressed, and pressed disabled buttons with WordPress Global CSS.