-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block Autocompleter: Force icon color to text color when item is selected #61376
Conversation
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 If 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. |
Size Change: +40 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
@@ -4,6 +4,10 @@ | |||
.block-editor-block-icon { | |||
margin-right: $grid-unit-10; | |||
} | |||
|
|||
&.is-selected .block-editor-block-icon { | |||
color: inherit !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a way to choose between coloured or block and white icons? Should we always choose black and white for autocomplete maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even !important
's can be overridden by plugins if they want it enough — at least until we can shadow-DOM these components :)
I'd tend to agree that color for blocks should be enforced in this view, it's a way to enforce contrast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a way to choose between coloured or block and white icons? Should we always choose black and white for autocomplete maybe?
If we choose white/black, I think all we need to do is delete showColors
here.
In my experience, some block plugins color their icons to highlight their branding. Therefore, I think it is better to respect the colored icon when the block is not selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me and works as expected 👍
Nice one. Thank you! |
Flaky tests detected in c807906. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10283260561
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, @t-hamano - thanks for the fix! 🚀
Follow up #60131
What?
This PR overrides the icon color in the Block Autocompleter popover when an item is selected, increasing icon visibility.
Why?
#60131 changed the background color of selected items to the primary color. In the block autocompleter, icons are rendered via the
BlockIcon
component. This component references theforeground
andbackground
of the icon prop and injects its color as inline styles. As a result, the icons are always the same color, which can reduce visibility.How?
When the button is selected, overrides the color of the block icon component with
inherit
. This will inherit the appropriate color and match the button text color.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
4c6ed0b0d02ed9920a3df9267b542383.mp4