Skip to content

PaletteEdit: Expose palette swatches as buttons for accessibility - #81836

Closed
dilipom13 wants to merge 11 commits into
WordPress:trunkfrom
dilipom13:fix/81800-palette-edit-as-buttons
Closed

dilipom13 wants to merge 11 commits into
WordPress:trunkfrom
dilipom13:fix/81800-palette-edit-as-buttons

Conversation

@dilipom13

Copy link
Copy Markdown
Contributor

Fixes #81800

What?

In Global Styles -> Edit palette, colour and gradient swatches were exposed as a listbox even though clicking one opens the edit popover.

Why?

Screen readers announce a listbox with options, but none are ever selected, and activation opens an editor, not a selection. That mismatch is what #81800 reports.

How?

Pass asButtons to the ColorPalette and GradientPicker inside PaletteEdit. Swatches become regular buttons instead of listbox options.

Also updates the style-variations e2e locators (role=option -> role=button).

Testing Instructions

  1. Appearance -> Editor -> Styles -> Colors -> Edit palette
  2. On the Colour tab, click a theme swatch — the edit popover should open
  3. Repeat on the Gradient tab
  4. In DevTools, confirm swatches use role=" button", not role=" option"

Testing Instructions for Keyboard

Same flow, keyboard only. Tab to a swatch and press Enter; the popover should open.

Use of AI Tools

None

@dilipom13
dilipom13 requested review from a team and ajitbohra as code owners August 19, 2026 19:35
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Components.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dilipom13 <dilip2615@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Package] Components /packages/components label Aug 19, 2026
@ciampo

ciampo commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

asButtons is the right direction, but it currently exposes each swatch as a toggle button through aria-pressed. These swatches are edit commands, not toggles.

Could we model the three supported presentations explicitly?

  1. Add this prop to CircularOptionPicker:

    presentation?: 'listbox' | 'toggle-buttons' | 'command-buttons';
  2. Forward it through ColorPalette, GradientPicker, and DuotonePicker.

  3. Deprecate asButtons, preserving it as an alias for presentation="toggle-buttons"

  4. Use presentation="command-buttons" for all three pickers in PaletteEdit.

command-buttons would render native buttons without aria-pressed, while existing selection consumers would keep their current behavior.

@WordPress/gutenberg-components what do you think?

@ramonjd ramonjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is working as intended, but pending review feedback

Just to note that #81605 adds a third picker (Duotone) and rewrites this same block. Whichever merges second would need to resolve that as well.

Cheers for getting it started!

Comment thread packages/components/CHANGELOG.md Outdated

- `Modal`: Prevent an Escape key press that dismisses the modal from propagating to underlying overlays. ([#81785](https://github.com/WordPress/gutenberg/pull/81785))
- `BoxControl`: Update the opposite side when ALT is held on the left or right input, which each updated themselves instead ([#81530](https://github.com/WordPress/gutenberg/pull/81530)).
- `PaletteEdit`: Expose palette swatches as buttons instead of a listbox, since activating a swatch opens the editor rather than selecting a value ([#81800](https://github.com/WordPress/gutenberg/issues/81800)).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- `PaletteEdit`: Expose palette swatches as buttons instead of a listbox, since activating a swatch opens the editor rather than selecting a value ([#81800](https://github.com/WordPress/gutenberg/issues/81800)).
- `PaletteEdit`: Expose palette swatches as buttons instead of a listbox, since activating a swatch opens the editor rather than selecting a value ([#81836](https://github.com/WordPress/gutenberg/pull/81836)).

@dilipom13
dilipom13 requested a review from ramonjd August 20, 2026 03:10
@ciampo

ciampo commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

@dilipom13 Let us know once you've addressed current review feedback, thank you 🙏 We're not going to do another round of review until then.

Alternatively, if you can't continue the work here, let us know and we'll close this PR (and open a new one to continue)

@dilipom13

Copy link
Copy Markdown
Contributor Author

@dilipom13 Let us know once you've addressed current review feedback, thank you 🙏 We're not going to do another round of review until then.

Alternatively, if you can't continue the work here, let us know and we'll close this PR (and open a new one to continue)

Thanks @ciampo
I'll work on the presentation prop approach and resolve the conflicts with #81605.
I'll ping you here once it's ready for another look.

Keep the Duotone picker from WordPress#81605 and apply asButtons to Color, Gradient, and Duotone swatches. Point the CHANGELOG entry at WordPress#81836.

Co-authored-by: Cursor <cursoragent@cursor.com>
@dilipom13
dilipom13 force-pushed the fix/81800-palette-edit-as-buttons branch from 3b5575a to e32c48c Compare August 21, 2026 18:52
dilipom13 and others added 3 commits August 22, 2026 01:10
Keep presentation off the DOM, restore aria-pressed for toggle buttons, and refresh the Storybook/docs snapshots.

Co-authored-by: Cursor <cursoragent@cursor.com>
Deprecated props still appear in the Storybook snapshot when the tag is not part of the description text.

Co-authored-by: Cursor <cursoragent@cursor.com>
@dilipom13

Copy link
Copy Markdown
Contributor Author

Hello @ciampo, I've addressed the feedback:

  • Added presentation (listbox | toggle-buttons | command-buttons) on CircularOptionPicker
  • Forwarded it through ColorPalette, GradientPicker, and DuotonePicker
  • Deprecated asButtons as an alias for toggle-buttons
  • PaletteEdit now uses presentation="command-buttons" on all three pickers
  • Resolved the trunk conflicts with Global Styles: Allow editing duotone palettes #81605

Ready for another look when you have a minute.

Please review it and let me know. if any thing missing from my side.

Thank you.

@ciampo ciampo left a comment •

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.

To complete the deprecation, we should also:

  • Migrate Cover and the story to presentation="toggle-buttons".
  • Keep asButtons supported and type-deprecated, but hide it from generated/public documentation (using the @ignore tag in the prop's JSDocs)
  • Emit the warning at each public picker boundary.
  • Test both compatibility and the warning.

We should update ColorPalette's README to document presentation, deprecate asButtons. While we're doing that, let's also correct the repeated loop description across Circular, Color, Gradient, and Duotone: loop applies only when the resolved presentation is listbox; explicit presentation takes precedence over asButtons.

Finally, the PR description is not out of date, let's update it to reflect latest changes and approach.

*
* @default 'listbox'
*/
presentation?: 'listbox' | 'toggle-buttons' | 'command-buttons';

@ciampo ciampo Aug 24, 2026 •

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.

presentation="command-buttons" can be combined with value or selectedSlug. All three pickers then show a selected check and clear the value when the selected button is activated, but command mode removes aria-pressed. This creates toggle behavior whose state is not exposed to assistive technology.

PaletteEdit is safe because it passes no selection prop, but the new public API permits this combination. Could command mode exclude value/selectedSlug, or ignore selection and selected-item clearing? Please test the chosen behavior through Color, Gradient, and Duotone.

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.

@dilipom13 this also still needs addressing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hello @ciampo

  • Migrated Cover and the CircularOptionPicker story to presentation="toggle-buttons"
  • Hid asButtons from docs / Storybook with @ignore (still supported and type-deprecated)
  • Added wrapper-level deprecation warnings on ColorPalette, GradientPicker, and DuotonePicker
  • Added compatibility + warning tests
  • Updated READMEs (presentation, corrected loop description)

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.

I believe this reply was meant for this thread, while this thread is still unaddressed.

asButtons
);

// Prefer `presentation` so wrappers do not keep passing deprecated `asButtons`.

@ciampo ciampo Aug 24, 2026 •

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 complete the package’s soft-deprecation sequence for asButtons?

The Components guidance is to hide the legacy API from documentation, migrate Gutenberg consumers, and only then add runtime warnings. Cover and the CircularOptionPicker story still use asButtons, while the public pickers convert it to presentation before the current warning can run.

Please migrate those consumers to presentation="toggle-buttons", hide asButtons from generated and manual docs while keeping it type-deprecated and supported, then warn at the ColorPalette, GradientPicker, and DuotonePicker boundaries. A wrapper-level compatibility and warning test would complete the deprecation path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay
So @ciampo do I need to do anything else from my side?

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.

Yup, pretty much everything listed in the previous comment and here 😅

  • Cover component and the CircularOptionPicker story still use asButtons, they should be refactored to the new presentation="toggle-buttons" prop;
  • The prop needs @ignore to its JSDocs comment; it needs to be removed from generated and manual docs, and from the Storybook manifest
  • Make the public ColorPalette, GradientPicker, and DuotonePicker wrappers also warn when the deprecated asButtons prop is received

@dilipom13
dilipom13 requested a review from ciampo August 24, 2026 11:11
dilipom13 and others added 2 commits August 24, 2026 17:05
Migrate Cover and stories to presentation, hide asButtons from docs, and warn at public picker boundaries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@dilipom13
dilipom13 requested a review from fabiankaegy as a code owner August 25, 2026 03:09
@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Aug 25, 2026
dilipom13 and others added 2 commits August 25, 2026 08:57
Storybook docgen still emits asButtons, so the snapshot must include it while the prop stays soft-deprecated in docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ciampo

ciampo commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

@dilipom13 I decided to continue the work in #82023 — the current feedback loop is too slow (I'm finding myself repeating the same feedback, previous feedback doesn't get addressed) and it's time-consuming for me as the reviewer.

I'll make sure to mention you as a co-author in the new PR. Thank you for your help!

@ciampo ciampo closed this Aug 25, 2026
@dilipom13

Copy link
Copy Markdown
Contributor Author

@dilipom13 I decided to continue the work in #82023 — the current feedback loop is too slow (I'm finding myself repeating the same feedback, previous feedback doesn't get addressed) and it's time-consuming for me as the reviewer.

I'll make sure to mention you as a co-author in the new PR. Thank you for your help!

Okay @ciampo

Am I experiencing the same issue on my end as well?

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

Labels

[Package] Block library /packages/block-library [Package] Components /packages/components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PaletteEdit swatch pickers are exposed as listboxes but act as edit commands

3 participants