diff --git a/packages/block-library/src/cover/edit/index.js b/packages/block-library/src/cover/edit/index.js index 6d9c8a790b20cd..b9b7f5d567319d 100644 --- a/packages/block-library/src/cover/edit/index.js +++ b/packages/block-library/src/cover/edit/index.js @@ -515,6 +515,7 @@ function CoverEdit( { onChange={ onSetOverlayColor } clearable={ false } asButtons + aria-label={ __( 'Background color' ) } /> diff --git a/packages/components/src/circular-option-picker/circular-option-picker.tsx b/packages/components/src/circular-option-picker/circular-option-picker.tsx index 8b6be8cd2215f0..c4309ecf4dda3d 100644 --- a/packages/components/src/circular-option-picker/circular-option-picker.tsx +++ b/packages/components/src/circular-option-picker/circular-option-picker.tsx @@ -132,7 +132,7 @@ function ButtonsCircularOptionPicker( ); return ( -
+
{ options } { children } diff --git a/packages/components/src/circular-option-picker/stories/index.story.tsx b/packages/components/src/circular-option-picker/stories/index.story.tsx index 9d45c9bb92f7d0..6b564929fd8eb9 100644 --- a/packages/components/src/circular-option-picker/stories/index.story.tsx +++ b/packages/components/src/circular-option-picker/stories/index.story.tsx @@ -131,7 +131,7 @@ WithLoopingDisabled.parameters = { docs: { source: { code: `} />`, diff --git a/packages/components/src/circular-option-picker/types.ts b/packages/components/src/circular-option-picker/types.ts index 411782aed575b1..65760092220999 100644 --- a/packages/components/src/circular-option-picker/types.ts +++ b/packages/components/src/circular-option-picker/types.ts @@ -40,7 +40,16 @@ type CommonCircularOptionPickerProps = { * The child elements. */ children?: ReactNode; -}; +} & ( + | { + 'aria-label': string; + 'aria-labelledby'?: never; + } + | { + 'aria-label'?: never; + 'aria-labelledby': string; + } +); type WithBaseId = { baseId: string; @@ -59,16 +68,7 @@ type FullListboxCircularOptionPickerProps = CommonCircularOptionPickerProps & { * @default true */ loop?: boolean; -} & ( - | { - 'aria-label': string; - 'aria-labelledby'?: never; - } - | { - 'aria-label'?: never; - 'aria-labelledby': string; - } - ); +}; export type ListboxCircularOptionPickerProps = WithBaseId & Omit< FullListboxCircularOptionPickerProps, 'asButtons' >; diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index de4e4f4206fe3a..68c4d339120a31 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -254,10 +254,27 @@ function UnforwardedColorPalette( let metaProps: | { asButtons: false; loop?: boolean; 'aria-label': string } | { asButtons: false; loop?: boolean; 'aria-labelledby': string } - | { asButtons: true }; + | { asButtons: true; 'aria-label': string } + | { asButtons: true; 'aria-labelledby': string }; if ( asButtons ) { - metaProps = { asButtons: true }; + const _metaProps: { asButtons: true } = { + asButtons: true, + }; + + if ( ariaLabel ) { + metaProps = { ..._metaProps, 'aria-label': ariaLabel }; + } else if ( ariaLabelledby ) { + metaProps = { + ..._metaProps, + 'aria-labelledby': ariaLabelledby, + }; + } else { + metaProps = { + ..._metaProps, + 'aria-label': __( 'Custom color picker.' ), + }; + } } else { const _metaProps: { asButtons: false; loop?: boolean } = { asButtons: false, diff --git a/packages/components/src/duotone-picker/duotone-picker.tsx b/packages/components/src/duotone-picker/duotone-picker.tsx index 8764b401c38296..ee8319b16183f6 100644 --- a/packages/components/src/duotone-picker/duotone-picker.tsx +++ b/packages/components/src/duotone-picker/duotone-picker.tsx @@ -130,10 +130,27 @@ function DuotonePicker( { let metaProps: | { asButtons: false; loop?: boolean; 'aria-label': string } | { asButtons: false; loop?: boolean; 'aria-labelledby': string } - | { asButtons: true }; + | { asButtons: true; 'aria-label': string } + | { asButtons: true; 'aria-labelledby': string }; if ( asButtons ) { - metaProps = { asButtons: true }; + const _metaProps: { asButtons: true } = { + asButtons: true, + }; + + if ( ariaLabel ) { + metaProps = { ..._metaProps, 'aria-label': ariaLabel }; + } else if ( ariaLabelledby ) { + metaProps = { + ..._metaProps, + 'aria-labelledby': ariaLabelledby, + }; + } else { + metaProps = { + ..._metaProps, + 'aria-label': __( 'Custom color picker.' ), + }; + } } else { const _metaProps: { asButtons: false; loop?: boolean } = { asButtons: false, diff --git a/packages/components/src/gradient-picker/index.tsx b/packages/components/src/gradient-picker/index.tsx index 28491d8a56010e..544faee848173c 100644 --- a/packages/components/src/gradient-picker/index.tsx +++ b/packages/components/src/gradient-picker/index.tsx @@ -131,10 +131,27 @@ function Component( props: PickerProps< any > ) { let metaProps: | { asButtons: false; loop?: boolean; 'aria-label': string } | { asButtons: false; loop?: boolean; 'aria-labelledby': string } - | { asButtons: true }; + | { asButtons: true; 'aria-label': string } + | { asButtons: true; 'aria-labelledby': string }; if ( asButtons ) { - metaProps = { asButtons: true }; + const _metaProps: { asButtons: true } = { + asButtons: true, + }; + + if ( ariaLabel ) { + metaProps = { ..._metaProps, 'aria-label': ariaLabel }; + } else if ( ariaLabelledby ) { + metaProps = { + ..._metaProps, + 'aria-labelledby': ariaLabelledby, + }; + } else { + metaProps = { + ..._metaProps, + 'aria-label': __( 'Custom color picker.' ), + }; + } } else { const _metaProps: { asButtons: false; loop?: boolean } = { asButtons: false,