Repository navigation
Components: Show pressed state of Button and Toolbar in forced colors mode - #86393
Conversation
…lors mode Forced colors discard the colors that mark a pressed button, so a pressed toggle looks the same as an unpressed one. Fill pressed buttons with the system selection colors, following the `@wordpress/ui` Button.
🤖 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: +1.45 kB (+0.02%) Total Size: 8.63 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. Page List converts to Navigation Links with entity bindings in
|
`ColorPalette` picks a check mark color that contrasts with the swatch, but forced colors replace the swatch with `Canvas`, so the check mark could match its background. Also handle disabled pressed buttons in the widgets header, where plugins can add them, and record why the swatch reset and the toolbar fill work the way they do.
|
It's a close call but I'm leaning towards not backporting this. This has been a long-standing bug, and there is a low-but-non-zero potential for third-party regressions. |
ciampo
left a comment
There was a problem hiding this comment.
LGTM 🚀
Is there any easy way to remove style overrides outside of components and ui packages?
Is the only clean way to prepare a new Toolbar component in the ui package and refactor to it?
Well, the todo I added about possibly having a way to opt out of the |
What?
Follow-up to #85948.
Makes the pressed state of the
@wordpress/componentsButtonand toolbar buttons visible in forced colors mode, for every variant and for disabled pressed buttons. Also keeps the check mark on selected color swatches visible, which is what marks the selection there.Why?
The pressed state is conveyed only by background and foreground color. Forced colors mode replaces both with system colors, so a pressed toggle looks the same as an unpressed one. This includes the common editor toggles, such as Bold in the block toolbar and the List View toggle in the document tools.
How?
This uses the same system selection colors as #85948, but with
!important, because opting out of color adjustment lets every other color rule that matches the button take effect, including the variants' high-specificity state rules and consumers' own pressed styles. Toolbar buttons fill their::beforeinstead, so the document tools headers, which hide it, restore the fill on the button itself.CircularOptionPickeroptions opt back in, because they paint their swatch with abox-shadowand mark selection with a check mark, which now uses a system color because forced colors replace the swatch it was chosen to contrast with.Testing Instructions
active.isPressedand confirm the button is filled with the selection color and its label is readable.disabledand confirm the button is filled with the gray disabled color and its label is readable.variantand confirm the same for each variant.darkand repeat.Testing Instructions for Keyboard
Screenshots or screencast