Repository navigation
Color picker: Custom color option - Edit Icon addition - #74930
Mayank-Tripathi32 wants to merge 2 commits into
Conversation
|
Thanks for contributing. I think this solution, designwise, can work, but I'd also think that if we are to be able to land it, we need to carefully make these edits since it's effectively touching the ColorPalette component. At a glance, the code looks mostly right, but there are a couple of details, I'll leave them as code comments. With no rush, this isn't urgent, @WordPress/gutenberg-components can you look? |
| inset -1 * $border-width 0 0 0 rgba(0, 0, 0, 0.2); | ||
| } | ||
|
|
||
| .components-color-palette__custom-color-edit-button { |
There was a problem hiding this comment.
Could we consider using an IconButton instead? The main motivation is that all of this CSS is duplicated already, multiple times across the code-base. That can be necessary at times, but in this case it can easily cause things to start to drift.
In doing so, it would also fix another issue: SVG colours should no longer be set using fill, but using color, and absent colour token changes that are on the way, the legacy icon colour is $gray-900.
| <button | ||
| className="components-color-palette__custom-color-edit-button" | ||
| aria-label={ __( 'Edit custom color' ) } | ||
| onClick={ onToggle } | ||
| type="button" | ||
| > | ||
| { displayValue } | ||
| </Truncate> | ||
| </VStack> | ||
| <Icon icon={ pencil } size={ 20 } /> | ||
| </button> |
There was a problem hiding this comment.
This adds a second button for the same popup. That is not inherently invalid, but it adds a redundant keyboard stop, omits aria-expanded, and currently breaks the RichText keyboard test.
Could we make the whole card one toggle in both the empty and selected states?
| height="16" | ||
| viewBox="0 0 24 24" | ||
| width="16" |
There was a problem hiding this comment.
Looks like the snapshot expects the icon to be 16 px, but the react code currently specifies 20. Which one is the correct size?
There was a problem hiding this comment.
I think it should be 20, but let me check again once
There was a problem hiding this comment.
Not blocking, but if it's the visible icon, by default and with very few exceptions, all icons should always be 24x24px.
# Conflicts: # packages/block-editor/src/components/color-palette/test/__snapshots__/control.jsdom.test.jsx.snap # packages/components/src/color-palette/index.tsx
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe custom color control now includes an accessible edit button with a pencil icon. Updated styles align the color information and define the button’s appearance and focus state. ChangesCustom color control
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The color palette adds a labeled pencil button to open the custom color picker and includes layout and focus styling. No merge-blocking risk is identified. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
packages/components/src/color-palette/index.tsxESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. Comment |
|
Separate from whether this PR should be moved forward, I have updated it so that feedback and tests can be executed. |
|
It seems a bit strange that there are two triggers for the custom color palette, but I don't think there are any downsides to proceeding with this PR. What does everyone think? If we can agree on moving forward with this, let's proceed with the code review and design feedback. |
Two triggers are a bit weird indeed, I wrote a comment about it here: #74930 (comment) In that comment, I also proposed an alternative approach:
What do folks think? |
|
I noticed that this PR conflicts with #79266. Specifically, this PR launches a custom color picker when the edit button is clicked, whereas #79266 displays an inline editing field. We probably need to decide on the behavior, taking into account what both PRs are trying to achieve. cc @juanfra
|
|
Thanks for the ping, @t-hamano! And thanks for working on this @Mayank-Tripathi32! This looks like a valid issue, and there's definitely some overlap. We’re both adding a control to the same row: this PR puts a pencil next to the color name/value to open the color picker, while #79266 adds edit/delete actions in that same spot below the swatch, but to edit the colors. If both land, we'd end up with two pencils next to each other meaning different things :) From what I understand, the main problem this PR is trying to solve is swatch discoverability. I wonder if we could address that a little more directly by making the swatch itself feel more interactive. Perhaps through button styling, a label, a tooltip, or some other hint that it opens a dropdown. That might help users discover the existing interaction without introducing another control. A few things make me a little hesitant about the pencil here:
Full disclosure, I may already have some ideas in mind for this area from the work of #79266. So, I'd be more than happy to think through how we could approach this and solve both problems. Just sharing my honest UX feedback here, and I'm very open to exploring solutions. |




closes #74736
What?
Adds a visible edit icon next to the "No color selected" text in the color picker to improve discoverability of the custom color option.
Why?
In usability testing, 3 out of 5 users struggled to figure out how to select a custom color. The checkerboard swatch that opens the custom color selector wasn't clearly interactive, so users didn't realize they could click it to choose a custom color.
How?
Testing Instructions
Screenshots or screencast
color.edit.icon.mov