Skip to content

Color picker: Custom color option - Edit Icon addition - #74930

Draft
Mayank-Tripathi32 wants to merge 2 commits into
WordPress:trunkfrom
Mayank-Tripathi32:try/feat-add-color-edit-icon
Draft

Mayank-Tripathi32 wants to merge 2 commits into
WordPress:trunkfrom
Mayank-Tripathi32:try/feat-add-color-edit-icon

Conversation

@Mayank-Tripathi32

Copy link
Copy Markdown
Member

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?

  • Added a pencil icon button next to the color name/value text in the custom color picker area
  • The icon is functional and opens the color picker dropdown when clicked
  • Styled with proper focus states for accessibility

Testing Instructions

  1. Open a post or page in the editor
  2. Insert a block that has color options (e.g., Paragraph, Heading)
  3. Open the block settings sidebar and find a color control (e.g., Text color)
  4. Observe the color palette UI - there should now be a pencil/edit icon visible next to "No color selected" text
  5. Click the edit icon - it should open the custom color picker dropdown
  6. Verify the icon also appears when a color is selected (showing color name instead)
  7. Verify keyboard focus states work on the edit button

Screenshots or screencast

color.edit.icon.mov

@jasmussen

Copy link
Copy Markdown
Contributor

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +311 to +318
<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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment on lines +211 to +213
height="16"
viewBox="0 0 24 24"
width="16"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the snapshot expects the icon to be 16 px, but the react code currently specifies 20. Which one is the correct size?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be 20, but let me check again once

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: b16e22b3-b64b-41ac-ae05-c816e8f5eec9

📥 Commits

Reviewing files that changed from the base of the PR and between 3dc6116 and 74391ab.

⛔ Files ignored due to path filters (1)
  • packages/block-editor/src/components/color-palette/test/__snapshots__/control.jsdom.test.jsx.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • packages/components/src/color-palette/index.tsx
  • packages/components/src/color-palette/style.scss

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Added an “Edit custom color” button to the color palette, allowing users to open the custom color picker.
    • Added a pencil icon to make the edit action more recognizable.
  • Style

    • Improved the layout and focus styling of the custom color controls.

Walkthrough

The 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.

Changes

Custom color control

Layer / File(s) Summary
Custom color entry point
packages/components/src/color-palette/index.tsx, packages/components/src/color-palette/style.scss
The color palette adds an edit button that toggles the custom color picker. The button includes an accessible label, pencil icon, centered layout, and focus styling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 74391

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: ciampo

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding an edit icon to the custom color picker option.
Description check ✅ Passed The description explains the custom color discoverability problem and describes the added edit button, picker behavior, and focus styling.
Linked Issues check ✅ Passed The changes address issue #74736 by adding a visible pencil button, opening the custom color picker on activation, supporting selected and unselected colors, and adding focus styling.
Out of Scope Changes check ✅ Passed The reviewed changes are limited to the color palette component and its styles. They directly support the linked issue objectives.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/components/src/color-palette/index.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


Comment @coderabbitai help to get the list of available commands.

@t-hamano t-hamano added the [Type] Enhancement A suggestion for improvement. label Sep 6, 2026
@t-hamano

t-hamano commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Separate from whether this PR should be moved forward, I have updated it so that feedback and tests can be executed.

@t-hamano

t-hamano commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

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.

@ciampo

ciampo commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

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:

Could we make the whole card one toggle in both the empty and selected states?

What do folks think?

@t-hamano

t-hamano commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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

State This PR #79266
Default image image
Click Edit Button image image

@juanfra

juanfra commented Sep 8, 2026

Copy link
Copy Markdown
Member

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:

  • It introduces a second control for an action that already has one, just a few pixels away.
  • The pencil is also shown when nothing is selected, so it often isn't editing anything that exists yet. I feel that normally, a pencil usually suggests modifying an existing item, which feels different from opening a picker.
  • It addresses the discoverability problem by adding another control, rather than making the existing swatch more discoverable. A user who doesn’t realize the swatch is interactive may not necessarily learn that from the pencil.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Color picker: Custom color option (checkerboard swatch) is not discoverable

5 participants