-
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
Add an outline when the color picker select box is focused #50609
Add an outline when the color picker select box is focused #50609
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @megane9988! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Thank you for working on this, @megane9988 ! The select dropdown in |
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.
Alright!
Since SelectControl
shows focus styles correctly in isolation (see Storybook), I looked into the ColorPicker
component to see if there was any anomaly in the code — and indeed I noticed that #34598 introduced styles that hide the input's backdrop, which happens to be what renders the focus outline.
Basically, we can undo your changes so far and simply remove the style overrides for the backdrop (expand to see suggested changes)
diff --git a/packages/components/src/color-picker/styles.ts b/packages/components/src/color-picker/styles.ts
index bf25707ba9..ca7a10bcfe 100644
--- a/packages/components/src/color-picker/styles.ts
+++ b/packages/components/src/color-picker/styles.ts
@@ -14,10 +14,7 @@ import { boxSizingReset } from '../utils';
import Button from '../button';
import { Flex } from '../flex';
import { HStack } from '../h-stack';
-import {
- BackdropUI,
- Container as InputControlContainer,
-} from '../input-control/styles/input-control-styles';
+import { Container as InputControlContainer } from '../input-control/styles/input-control-styles';
import CONFIG from '../utils/config-values';
export const NumberControlWrapper = styled( NumberControl )`
@@ -29,9 +26,6 @@ export const NumberControlWrapper = styled( NumberControl )`
export const SelectControl = styled( InnerSelectControl )`
margin-left: ${ space( -2 ) };
width: 5em;
- ${ BackdropUI } {
- display: none;
- }
`;
export const RangeControl = styled( InnerRangeControl )`
Here's what the component looks like after these changes:
color.picker.select.focus.mp4
Finally, could you add an entry to the package's CHANGELOG, in the "Unreleased" section? You may need to create a new "Bug Fix" sub-section.
cc @jasmussen, to make you aware of this fix. Side note: should we look at updating focus styles for the two circular drag handles too, so that they show the same blue ring as the rest of the UI?
The
In #34598 Ideally, we shouldn't hack around //Cc @ciampo If a new
|
Thank you for the comment, @afercia. I agree that we should try to limit the ad-hoc style overrides when we use components, and instead aim for consistency. Would it be ok for the As an alternative (although definitely not my favorite option), we could enable |
Appreciate your comment. As a first confirmation, we should give an outline when we focus. Then, from the discussion between the two of you
These are the opinions that have been expressed. So possible ways to outline when focusing are
It is one of these two. The latter is considered less time-consuming to implement, but since this one is #34598 and will modify the design itself as suggested by others, we may need to check with the person who was in charge of the design. In addition, in that case, this PR should be put on hold, This would take a lot of time for discussion. First, should we use this PR to realize the display of the outer frame only when the focus is on it? Please let us know which you think is better. |
@ciampo I guess we posted our previous comments almost at the same time :D
If you ask me, that would be the preferred option to me. Any interactive control should be clearly distinguishable which in most cases translates to using a shape e.g. a border. In this specific case, the redesign in #34598 asked to remove the border... 😭 |
@jasmussen do you have any feedback related to this situation? I tried to propose a few potential alternatives in a previous message |
The underlying technical point here is that the inputControl component (and BackdropUI) should provide the default style and the focus style our-of-the-box. We should avoid to override components styles with ad-hoc customizations. Also from a consistency perspective, I'm not sure why all the select dropdowns are expected to havre a default gray border and this specific dropdown doesn't. To me, UI consistency is more important than aesthetics. Note: the styles of this component are provided via styled components (JS) and can't use scss mixins. |
Understood. Agreed that this should use base componentry with no overrides. I don't see this as a regular dropdown, though, for me it is comparable to an ellipsis menu. We can remove the down chevron if that helps. It's a toggle moreso than a select. |
Let's approach this iteratively. The urgent part is to make sure that diff --git a/packages/components/src/color-picker/styles.ts b/packages/components/src/color-picker/styles.ts
index bf25707ba9..f78db13a8f 100644
--- a/packages/components/src/color-picker/styles.ts
+++ b/packages/components/src/color-picker/styles.ts
@@ -29,8 +29,13 @@ export const NumberControlWrapper = styled( NumberControl )`
export const SelectControl = styled( InnerSelectControl )`
margin-left: ${ space( -2 ) };
width: 5em;
- ${ BackdropUI } {
- display: none;
+ /*
+ * Remove border, but preserve focus styles
+ * TODO: this override should be removed,
+ * see https://github.com/WordPress/gutenberg/pull/50609
+ */
+ select:not( :focus ) ~ ${ BackdropUI }${ BackdropUI }${ BackdropUI } {
+ border-color: transparent;
}
`; It is hacky, but it will get the job done. Separately, we can discuss better about the long-term solution:
What do folks think ?? |
I want to follow @ciampo 's idea. |
a5f90c3
to
064f731
Compare
I am following @ciampo 's idea, and I rewrote a PR again. Of course, it's necessary to reconsider the relevant component. What do you think? Please give us your opinion. |
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.
I think this is a good compromise for the short term, thank you!
I will leave a final review once conflicts are solved
add empty line Co-authored-by: Marco Ciampini <[email protected]>
@ciampo, thank you. I added an empty line. |
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.
LGTM, thank everyone else for the collaboration!
@megane9988 feel free to ping me if you ever feel like doing more work on the @wordpress/components
, always happy to help / review
What?
Add an outline when the color picker select box is focused.
Why?
Fixes #50524
How?
add CSSIn #34598, there was a problem when the border of a select box was hidden, the focus outline disappeared along with the border. Therefore, the CSS is modified so the focus outline does not disappear.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
storybook
before
after
editor