Skip to content

Commit

Permalink
ColorPalette: Disable Clear button if there's no color value. (#67108)
Browse files Browse the repository at this point in the history
* Disable `Clear` button if there's no color value.

* Add changelog entry.

* Add PR to changelog entry.

* Set gradient and duotone clear button as disabled if there's no value. Add `accessibleWhenDisabled` for all the changes.

Co-authored-by: juanfra <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: afercia <[email protected]>
  • Loading branch information
4 people authored Nov 20, 2024
1 parent 7639ed8 commit b408e17
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

- `ToggleGroupControl`: Fix active background for `0` value ([#66855](https://github.com/WordPress/gutenberg/pull/66855)).
- `SlotFill`: Fix a bug where a stale value of `fillProps` could be used ([#67000](https://github.com/WordPress/gutenberg/pull/67000)).
- `ColorPalette`: Disable `Clear` button if there's no color value. ([#67108](https://github.com/WordPress/gutenberg/pull/67108)).
- `GradientPicker`: Disable `Clear` button if there's no value. ([#67108](https://github.com/WordPress/gutenberg/pull/67108)).
- `DuotonePicker`: Disable `Clear` button if there's no value. ([#67108](https://github.com/WordPress/gutenberg/pull/67108)).
- `ColorPicker`: Add accessible label for copy button ([#67094](https://github.com/WordPress/gutenberg/pull/67094)).

### Enhancements
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/color-palette/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ function UnforwardedColorPalette(
};

const actions = !! clearable && (
<CircularOptionPicker.ButtonAction onClick={ clearColor }>
<CircularOptionPicker.ButtonAction
onClick={ clearColor }
accessibleWhenDisabled
disabled={ ! value }
>
{ __( 'Clear' ) }
</CircularOptionPicker.ButtonAction>
);
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/duotone-picker/duotone-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ function DuotonePicker( {
!! clearable && (
<CircularOptionPicker.ButtonAction
onClick={ () => onChange( undefined ) }
accessibleWhenDisabled
disabled={ ! value }
>
{ __( 'Clear' ) }
</CircularOptionPicker.ButtonAction>
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/gradient-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ export function GradientPicker( {
! disableCustomGradients && (
<CircularOptionPicker.ButtonAction
onClick={ clearGradient }
accessibleWhenDisabled
disabled={ ! value }
>
{ __( 'Clear' ) }
</CircularOptionPicker.ButtonAction>
Expand Down

1 comment on commit b408e17

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in b408e17.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11931721481
📝 Reported issues:

Please sign in to comment.