From 51a44c3e54f157bf8ae8d65e88b6bba2a5ea979b Mon Sep 17 00:00:00 2001 From: Ramon Date: Wed, 22 Jul 2026 15:01:14 +1000 Subject: [PATCH 1/5] Components: add slug-based selection to GradientPicker GradientPicker marked selection by comparing gradient strings and its onChange reported only the string, so two presets sharing a gradient were indistinguishable: both rendered as selected, and consumers re-encoding the string could only ever resolve the first entry. Add an optional selectedSlug prop that selects strictly by slug when set, and pass the clicked preset's slug as a third onChange argument. Mirrors ColorPalette's selectedSlug API. Both changes are additive; existing consumers are unaffected. --- .../components/src/gradient-picker/README.md | 24 ++- .../components/src/gradient-picker/index.tsx | 71 +++++---- .../gradient-picker/stories/index.story.tsx | 6 +- .../src/gradient-picker/test/index.tsx | 148 ++++++++++++++++++ .../components/src/gradient-picker/types.ts | 28 +++- 5 files changed, 239 insertions(+), 38 deletions(-) create mode 100644 packages/components/src/gradient-picker/test/index.tsx diff --git a/packages/components/src/gradient-picker/README.md b/packages/components/src/gradient-picker/README.md index e97654e0f2be92..0f45e86603ac04 100644 --- a/packages/components/src/gradient-picker/README.md +++ b/packages/components/src/gradient-picker/README.md @@ -141,11 +141,29 @@ Only used when `asButtons` is not true. ### `onChange` - - Type: `(currentGradient: string | undefined) => void` + - Type: `(currentGradient: string | undefined, index?: number | undefined, slug?: string | undefined) => void` - Required: Yes -The function called when a new gradient has been defined. It is passed to -the `currentGradient` as an argument. +The function called when a new gradient has been defined. It is passed +the `currentGradient` as an argument. When a predefined gradient is +selected, the second argument is its index (or, for multiple-origin +gradients, the origin index) and the third argument is its slug. + +### `selectedSlug` + + - Type: `string` + - Required: No + +The slug of the currently selected predefined gradient. + +When set to a non-empty string, selection is determined by slug rather +than by gradient value, which correctly handles palettes where two +entries share the same gradient. Entries whose slug does not match will +not appear selected in this mode, even if their gradient value matches +`value`. + +An empty string is treated the same as `undefined`: selection falls +back to matching by gradient value. ### `value` diff --git a/packages/components/src/gradient-picker/index.tsx b/packages/components/src/gradient-picker/index.tsx index 63867f5e970a47..6708757fbedcb4 100644 --- a/packages/components/src/gradient-picker/index.tsx +++ b/packages/components/src/gradient-picker/index.tsx @@ -41,35 +41,48 @@ function SingleOrigin( { gradients, onChange, value, + selectedSlug, ...additionalProps }: PickerProps< GradientObject > ) { const gradientOptions = useMemo( () => { - return gradients.map( ( { gradient, name, slug }, index ) => ( - onChange( gradient, index ) - } - aria-label={ - name - ? // translators: %s: The name of the gradient e.g: "Angular red to blue". - sprintf( __( 'Gradient: %s' ), name ) - : // translators: %s: gradient code e.g: "linear-gradient(90deg, rgba(98,16,153,1) 0%, rgba(172,110,22,1) 100%);". - sprintf( __( 'Gradient code: %s' ), gradient ) - } - /> - ) ); - }, [ gradients, value, onChange, clearGradient ] ); + return gradients.map( ( { gradient, name, slug }, index ) => { + // When a non-empty selectedSlug is provided, selection is decided + // strictly by slug, which keeps two entries with the same gradient + // value apart. Otherwise selection falls back to matching the + // gradient value. + const isSelected = selectedSlug + ? slug === selectedSlug + : value === gradient; + return ( + onChange( gradient, index, slug ) + } + aria-label={ + name + ? // translators: %s: The name of the gradient e.g: "Angular red to blue". + sprintf( __( 'Gradient: %s' ), name ) + : // translators: %s: gradient code e.g: "linear-gradient(90deg, rgba(98,16,153,1) 0%, rgba(172,110,22,1) 100%);". + sprintf( __( 'Gradient code: %s' ), gradient ) + } + /> + ); + } ); + }, [ gradients, value, onChange, clearGradient, selectedSlug ] ); return ( ) { const instanceId = useInstanceId( MultipleOrigin ); @@ -101,10 +115,11 @@ function MultipleOrigin( { - onChange( gradient, index ) + onChange={ ( gradient, _index, slug ) => + onChange( gradient, index, slug ) } value={ value } + selectedSlug={ selectedSlug } aria-labelledby={ id } /> diff --git a/packages/components/src/gradient-picker/stories/index.story.tsx b/packages/components/src/gradient-picker/stories/index.story.tsx index 2f4b2e84a24423..c12cfcc508b019 100644 --- a/packages/components/src/gradient-picker/stories/index.story.tsx +++ b/packages/components/src/gradient-picker/stories/index.story.tsx @@ -99,9 +99,9 @@ const Template = ( { { - setGradient( ...changeArgs ); - onChange?.( ...changeArgs ); + onChange={ ( currentGradient, index, slug ) => { + setGradient( currentGradient ); + onChange?.( currentGradient, index, slug ); } } /> ); diff --git a/packages/components/src/gradient-picker/test/index.tsx b/packages/components/src/gradient-picker/test/index.tsx new file mode 100644 index 00000000000000..8023eb7a2ef83e --- /dev/null +++ b/packages/components/src/gradient-picker/test/index.tsx @@ -0,0 +1,148 @@ +/** + * External dependencies + */ +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; + +/** + * Internal dependencies + */ +import GradientPicker from '..'; + +const GRADIENT_A = + 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)'; +const GRADIENT_B = + 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)'; + +const DUPLICATE_GRADIENTS = [ + { name: 'Dark Background', slug: 'dark-background', gradient: GRADIENT_A }, + { name: 'Dark Text', slug: 'dark-text', gradient: GRADIENT_A }, +]; + +describe( 'GradientPicker', () => { + describe( 'duplicate gradients in palette', () => { + it( 'should render all swatches even when two entries share the same gradient value', () => { + render( + + ); + + expect( screen.getAllByRole( 'option' ) ).toHaveLength( 2 ); + } ); + + it( 'should select by slug when selectedSlug is provided, marking only the matching entry', () => { + render( + + ); + + const options = screen.getAllByRole( 'option' ); + // "dark-background" is index 0, "dark-text" is index 1. + expect( options[ 0 ] ).toHaveAttribute( 'aria-selected', 'false' ); + expect( options[ 1 ] ).toHaveAttribute( 'aria-selected', 'true' ); + } ); + + it( 'should fall back to value selection and mark all matching duplicates when no selectedSlug is provided', () => { + render( + + ); + + const options = screen.getAllByRole( 'option' ); + expect( options[ 0 ] ).toHaveAttribute( 'aria-selected', 'true' ); + expect( options[ 1 ] ).toHaveAttribute( 'aria-selected', 'true' ); + } ); + + it( 'should treat an empty-string selectedSlug as no slug and fall back to value selection', () => { + render( + + ); + + const options = screen.getAllByRole( 'option' ); + expect( options[ 0 ] ).toHaveAttribute( 'aria-selected', 'true' ); + expect( options[ 1 ] ).toHaveAttribute( 'aria-selected', 'true' ); + } ); + + it( 'should pass slug as third argument to onChange when a swatch is clicked', async () => { + const user = userEvent.setup(); + const onChange = jest.fn(); + + render( + + ); + + await user.click( + screen.getByRole( 'option', { name: 'Gradient: Dark Text' } ) + ); + + expect( onChange ).toHaveBeenCalledWith( + GRADIENT_A, + 1, + 'dark-text' + ); + } ); + + it( 'should pass slug as third argument to onChange for multiple-origin gradients', async () => { + const user = userEvent.setup(); + const onChange = jest.fn(); + + render( + + ); + + await user.click( + screen.getByRole( 'option', { name: 'Gradient: Blush' } ) + ); + + // The second argument is the origin index, mirroring the existing + // multiple-origin behavior. + expect( onChange ).toHaveBeenCalledWith( GRADIENT_B, 0, 'blush' ); + } ); + } ); +} ); diff --git a/packages/components/src/gradient-picker/types.ts b/packages/components/src/gradient-picker/types.ts index 3497dd8c5ac008..4d6fb89d74b760 100644 --- a/packages/components/src/gradient-picker/types.ts +++ b/packages/components/src/gradient-picker/types.ts @@ -17,10 +17,16 @@ type GradientPickerBaseProps = { */ className?: string; /** - * The function called when a new gradient has been defined. It is passed to - * the `currentGradient` as an argument. + * The function called when a new gradient has been defined. It is passed + * the `currentGradient` as an argument. When a predefined gradient is + * selected, the second argument is its index (or, for multiple-origin + * gradients, the origin index) and the third argument is its slug. */ - onChange: ( currentGradient: string | undefined ) => void; + onChange: ( + currentGradient: string | undefined, + index?: number, + slug?: string + ) => void; /** * The current value of the gradient. Pass a css gradient string (See default value for example). * Optionally pass in a `null` value to specify no gradient is currently selected. @@ -28,6 +34,19 @@ type GradientPickerBaseProps = { * @default 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)' */ value?: GradientObject[ 'gradient' ] | null; + /** + * The slug of the currently selected predefined gradient. + * + * When set to a non-empty string, selection is determined by slug rather + * than by gradient value, which correctly handles palettes where two + * entries share the same gradient. Entries whose slug does not match will + * not appear selected in this mode, even if their gradient value matches + * `value`. + * + * An empty string is treated the same as `undefined`: selection falls + * back to matching by gradient value. + */ + selectedSlug?: string; /** * Whether the palette should have a clearing button or not. * @@ -121,7 +140,8 @@ export type PickerProps< TOriginType extends GradientObject | OriginObject > = clearGradient: () => void; onChange: ( currentGradient: string | undefined, - index: number + index: number, + slug?: string ) => void; actions?: React.ReactNode; gradients: TOriginType[]; From eeda7a5608d3bdbbfaf4a26ad4cc2958b10aa21b Mon Sep 17 00:00:00 2001 From: Ramon Date: Wed, 22 Jul 2026 15:05:43 +1000 Subject: [PATCH 2/5] Global styles panels: keep gradient preset identity when presets share a gradient Same fix as the color presets in #80497, applied to gradients. The gradient tabs now pass the inherited and user slugs, the picker selects by slug, encodeGradientValue uses a provided slug instead of matching the gradient string, and accepting an inherited gradient commits its slug. Covers the background gradient, legacy color.gradient, and element gradient controls. --- .../components/colors-gradients/control.js | 9 +- .../global-styles/background-panel.js | 26 +++++- .../color-gradient-dropdown-item.js | 1 + .../components/global-styles/color-panel.js | 12 ++- .../src/components/global-styles/hooks.js | 9 +- .../global-styles/test/background-panel.js | 83 +++++++++++++++++++ 6 files changed, 130 insertions(+), 10 deletions(-) diff --git a/packages/block-editor/src/components/colors-gradients/control.js b/packages/block-editor/src/components/colors-gradients/control.js index 02b8d5cf8f3249..e4c4aeb4ba3fb2 100644 --- a/packages/block-editor/src/components/colors-gradients/control.js +++ b/packages/block-editor/src/components/colors-gradients/control.js @@ -45,6 +45,7 @@ function ColorGradientControlInner( { colorValue, colorSlug, gradientValue, + gradientSlug, clearable, showTitle = true, enableAlpha, @@ -102,13 +103,15 @@ function ColorGradientControlInner( { [ TAB_IDS.gradient ]: ( { - onGradientChange( newGradient ); + ? ( newGradient, _index, newSlug ) => { + onGradientChange( newGradient, newSlug ); onColorChange(); } - : onGradientChange + : ( newGradient, _index, newSlug ) => + onGradientChange( newGradient, newSlug ) } { ...{ gradients, disableCustomGradients } } __experimentalIsRenderedInSidebar={ diff --git a/packages/block-editor/src/components/global-styles/background-panel.js b/packages/block-editor/src/components/global-styles/background-panel.js index 912a9515de9b33..c899158569c23f 100644 --- a/packages/block-editor/src/components/global-styles/background-panel.js +++ b/packages/block-editor/src/components/global-styles/background-panel.js @@ -297,11 +297,11 @@ export default function BackgroundImagePanel( { // Legacy `color.gradient` setters. const legacyColorGradient = decodeValue( inheritedValue?.color?.gradient ); const userLegacyColorGradient = decodeValue( value?.color?.gradient ); - const setLegacyColorGradient = ( newGradient ) => { + const setLegacyColorGradient = ( newGradient, newSlug ) => { const newValue = setImmutably( value, [ 'color', 'gradient' ], - encodeGradientValue( newGradient ) + encodeGradientValue( newGradient, newSlug ) ); newValue.color.background = undefined; onChange( newValue ); @@ -323,11 +323,11 @@ export default function BackgroundImagePanel( { // Set gradient value, encoding preset matches as slug references. // Also clear color.gradient to migrate from the legacy location, // matching the block inspector behavior in hooks/background.js. - const setGradient = ( newGradient ) => { + const setGradient = ( newGradient, newSlug ) => { let newValue = setImmutably( value, [ 'background', 'gradient' ], - encodeGradientValue( newGradient ) + encodeGradientValue( newGradient, newSlug ) ); newValue = setImmutably( newValue, [ 'color', 'gradient' ], undefined ); onChange( newValue ); @@ -450,6 +450,16 @@ export default function BackgroundImagePanel( { key: 'gradient', label: __( 'Gradient' ), inheritedValue: inheritedGradient, + inheritedSlug: extractPresetSlug( + inheritedValue?.background?.gradient ?? + inheritedValue?.color?.gradient, + 'gradient' + ), + userSlug: extractPresetSlug( + value?.background?.gradient ?? + value?.color?.gradient, + 'gradient' + ), setValue: setGradient, userValue: currentGradient, isGradient: true, @@ -487,6 +497,14 @@ export default function BackgroundImagePanel( { key: 'gradient', label: __( 'Gradient' ), inheritedValue: legacyColorGradient, + inheritedSlug: extractPresetSlug( + inheritedValue?.color?.gradient, + 'gradient' + ), + userSlug: extractPresetSlug( + value?.color?.gradient, + 'gradient' + ), setValue: setLegacyColorGradient, userValue: userLegacyColorGradient, isGradient: true, diff --git a/packages/block-editor/src/components/global-styles/color-gradient-dropdown-item.js b/packages/block-editor/src/components/global-styles/color-gradient-dropdown-item.js index 701e9e62951f3e..47247f3662c6be 100644 --- a/packages/block-editor/src/components/global-styles/color-gradient-dropdown-item.js +++ b/packages/block-editor/src/components/global-styles/color-gradient-dropdown-item.js @@ -170,6 +170,7 @@ function ColorGradientTab( { colorValue={ isGradient ? undefined : displayed } colorSlug={ isGradient ? undefined : displayedSlug } gradientValue={ isGradient ? displayed : undefined } + gradientSlug={ isGradient ? displayedSlug : undefined } onColorChange={ isGradient ? undefined : onChange } onGradientChange={ isGradient ? onChange : undefined } /* diff --git a/packages/block-editor/src/components/global-styles/color-panel.js b/packages/block-editor/src/components/global-styles/color-panel.js index f3b244c6c91392..cd4e92b9ff3aad 100644 --- a/packages/block-editor/src/components/global-styles/color-panel.js +++ b/packages/block-editor/src/components/global-styles/color-panel.js @@ -423,11 +423,11 @@ export default function ColorPanel( { newValue.elements[ name ].color.gradient = undefined; onChange( newValue ); }; - const setElementGradient = ( newGradient ) => { + const setElementGradient = ( newGradient, newSlug ) => { const newValue = setImmutably( value, [ 'elements', name, 'color', 'gradient' ], - encodeGradientValue( newGradient ) + encodeGradientValue( newGradient, newSlug ) ); newValue.elements[ name ].color.background = undefined; onChange( newValue ); @@ -516,6 +516,14 @@ export default function ColorPanel( { key: 'gradient', label: __( 'Gradient' ), inheritedValue: elementGradient, + inheritedSlug: extractPresetSlug( + inheritedValue?.elements?.[ name ]?.color?.gradient, + 'gradient' + ), + userSlug: extractPresetSlug( + value?.elements?.[ name ]?.color?.gradient, + 'gradient' + ), setValue: setElementGradient, userValue: elementGradientUserColor, isGradient: true, diff --git a/packages/block-editor/src/components/global-styles/hooks.js b/packages/block-editor/src/components/global-styles/hooks.js index d9f3830cd2cabe..baba0cb53d4fc0 100644 --- a/packages/block-editor/src/components/global-styles/hooks.js +++ b/packages/block-editor/src/components/global-styles/hooks.js @@ -328,7 +328,14 @@ export function useColorGradientSettings( settings ) { ); const decodeValue = ( rawValue ) => getValueFromVariable( { settings }, '', rawValue ); - const encodeGradientValue = ( gradientValue ) => { + // When a slug is provided it is used directly: two presets can share the + // same gradient string, and matching by string alone would collapse them + // onto whichever entry appears first. Without a slug, fall back to + // matching the gradient string against the presets. + const encodeGradientValue = ( gradientValue, slug ) => { + if ( slug ) { + return 'var:preset|gradient|' + slug; + } const allGradients = gradients.flatMap( ( { gradients: originGradients } ) => originGradients ); diff --git a/packages/block-editor/src/components/global-styles/test/background-panel.js b/packages/block-editor/src/components/global-styles/test/background-panel.js index 8b8fd7750769a9..69e38e5ad8c1fa 100644 --- a/packages/block-editor/src/components/global-styles/test/background-panel.js +++ b/packages/block-editor/src/components/global-styles/test/background-panel.js @@ -130,6 +130,89 @@ const baseSettings = { }, }; +describe( 'BackgroundPanel — duplicate gradient preset slug identity', () => { + const SHARED_GRADIENT = + 'linear-gradient(135deg, rgb(74, 0, 224) 0%, rgb(142, 45, 226) 100%)'; + const duplicateGradientSettings = { + background: { + gradient: true, + }, + color: { + gradients: { + theme: [ + { + name: 'Dark background', + slug: 'dup-background', + gradient: SHARED_GRADIENT, + }, + { + name: 'Dark text', + slug: 'dup-text', + gradient: SHARED_GRADIENT, + }, + ], + }, + }, + }; + + async function openGradientDropdown( user ) { + await user.click( screen.getByRole( 'button', { name: /Gradient/ } ) ); + return screen.findAllByRole( 'option' ); + } + + it( 'commits the inherited preset slug when accepting the preselected inherited gradient', async () => { + const user = userEvent.setup(); + const onChange = jest.fn(); + + render( + + ); + + const swatches = await openGradientDropdown( user ); + // swatch[1] ('Dark text') is the preselected inherited option; + // activating it is the "accept inherited value" gesture. The commit + // must carry the inherited slug, not re-encode the shared gradient + // string to whichever duplicate appears first. + await user.click( swatches[ 1 ] ); + + const result = onChange.mock.calls[ 0 ][ 0 ]; + expect( result?.background?.gradient ).toBe( + 'var:preset|gradient|dup-text' + ); + } ); + + it( 'marks only the local preset as selected when another preset shares its gradient', async () => { + const user = userEvent.setup(); + + render( + + ); + + // swatch[0] = 'Dark background', swatch[1] = 'Dark text'. Selection + // must follow the stored slug; matching by gradient string would + // mark both. + const swatches = await openGradientDropdown( user ); + expect( swatches[ 1 ] ).toHaveAttribute( 'aria-selected', 'true' ); + expect( swatches[ 0 ] ).toHaveAttribute( 'aria-selected', 'false' ); + } ); +} ); + describe( 'BackgroundPanel — inherited Global Styles label treatment', () => { describe( 'Background gradient slot', () => { it( 'applies the local-override className when a local gradient is set', () => { From ed60d9e49db5dad9c929e1f2cadf4804c67560c1 Mon Sep 17 00:00:00 2001 From: Ramon Date: Wed, 22 Jul 2026 15:16:43 +1000 Subject: [PATCH 3/5] Components: add GradientPicker selectedSlug changelog entry --- packages/components/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index fd90ae508537c1..8e832a96fc2342 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Enhancements + +- `GradientPicker`: Add `selectedSlug` prop for slug-based selection and pass the selected preset's slug to `onChange`, so two presets sharing a gradient keep their identity ([#80554](https://github.com/WordPress/gutenberg/pull/80554)). + ### Bug Fixes - `Autocomplete`: Expose the suggestions list to assistive technology with `aria-controls` and `aria-haspopup`, both required alongside `aria-autocomplete="list"` ([#80403](https://github.com/WordPress/gutenberg/pull/80403)). From 3f21e2cb14239333fb012c4eeb33a7357e37e573 Mon Sep 17 00:00:00 2001 From: Ramon Date: Thu, 23 Jul 2026 11:47:23 +1000 Subject: [PATCH 4/5] Components: cover selectedSlug in the GradientPicker story The story template now tracks the selected slug alongside the gradient, matching the ColorPalette story, and a DuplicateGradients story shows two presets sharing a gradient string with slug-based selection. --- .../gradient-picker/stories/index.story.tsx | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/packages/components/src/gradient-picker/stories/index.story.tsx b/packages/components/src/gradient-picker/stories/index.story.tsx index c12cfcc508b019..54f7d35e07313a 100644 --- a/packages/components/src/gradient-picker/stories/index.story.tsx +++ b/packages/components/src/gradient-picker/stories/index.story.tsx @@ -31,6 +31,7 @@ const meta: Meta< typeof GradientPicker > = { onChange: fn(), }, argTypes: { + selectedSlug: { control: false }, value: { control: false }, }, }; @@ -91,17 +92,23 @@ const GRADIENTS = [ const Template = ( { onChange, + value, + selectedSlug, ...props }: React.ComponentProps< typeof GradientPicker > ) => { - const [ gradient, setGradient ] = - useState< ( typeof props )[ 'value' ] >( null ); + const [ gradient, setGradient ] = useState< ( typeof props )[ 'value' ] >( + value ?? null + ); + const [ slug, setSlug ] = useState< string | undefined >( selectedSlug ); return ( { + selectedSlug={ slug } + onChange={ ( currentGradient, index, newSlug ) => { setGradient( currentGradient ); - onChange?.( currentGradient, index, slug ); + setSlug( newSlug ); + onChange?.( currentGradient, index, newSlug ); } } /> ); @@ -121,6 +128,35 @@ export const WithNoExistingGradients: GradientPickerStory = { }, }; +export const DuplicateGradients: GradientPickerStory = { + render: Template, + args: { + gradients: [ + { + name: 'Dark Background', + slug: 'dark-background', + gradient: + 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', + }, + { + name: 'Dark Text', + slug: 'dark-text', + gradient: + 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', + }, + { + name: 'Brand', + slug: 'brand', + gradient: + 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)', + }, + ], + value: 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', + selectedSlug: 'dark-text', + disableCustomGradients: true, + }, +}; + export const MultipleOrigins: GradientPickerStory = { render: Template, args: { From db2f85eb91400ae229ab324a2d5c873beae531d0 Mon Sep 17 00:00:00 2001 From: Ramon Date: Thu, 23 Jul 2026 11:47:57 +1000 Subject: [PATCH 5/5] Components: fix gradient state type in GradientPicker story template --- .../components/src/gradient-picker/stories/index.story.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/components/src/gradient-picker/stories/index.story.tsx b/packages/components/src/gradient-picker/stories/index.story.tsx index 54f7d35e07313a..6386d55d4415cb 100644 --- a/packages/components/src/gradient-picker/stories/index.story.tsx +++ b/packages/components/src/gradient-picker/stories/index.story.tsx @@ -96,9 +96,9 @@ const Template = ( { selectedSlug, ...props }: React.ComponentProps< typeof GradientPicker > ) => { - const [ gradient, setGradient ] = useState< ( typeof props )[ 'value' ] >( - value ?? null - ); + const [ gradient, setGradient ] = useState< + React.ComponentProps< typeof GradientPicker >[ 'value' ] + >( value ?? null ); const [ slug, setSlug ] = useState< string | undefined >( selectedSlug ); return (