diff --git a/packages/components/src/toggle-group-control/test/__snapshots__/index.tsx.snap b/packages/components/src/toggle-group-control/test/__snapshots__/index.tsx.snap index 8c744d75f5c442..0a709494f49758 100644 --- a/packages/components/src/toggle-group-control/test/__snapshots__/index.tsx.snap +++ b/packages/components/src/toggle-group-control/test/__snapshots__/index.tsx.snap @@ -143,6 +143,7 @@ exports[`ToggleGroupControl should render correctly with icons 1`] = ` z-index: 2; color: #1e1e1e; width: 30px; + height: 30px; padding-left: 0; padding-right: 0; color: #fff; @@ -211,6 +212,7 @@ exports[`ToggleGroupControl should render correctly with icons 1`] = ` z-index: 2; color: #1e1e1e; width: 30px; + height: 30px; padding-left: 0; padding-right: 0; } diff --git a/packages/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx b/packages/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx index e1d90fc1085a29..3c807ed9746d10 100644 --- a/packages/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx +++ b/packages/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx @@ -66,26 +66,33 @@ function ToggleGroupControlOptionBase( const { className, isIcon = false, + isMultiple = false, value, children, showTooltip = false, ...otherButtonProps } = buttonProps; - const isPressed = otherContextProps.state === value; + const isPressed = + otherContextProps.state === value || + otherButtonProps[ 'aria-pressed' ] === true; const cx = useCx(); const labelViewClasses = cx( isBlock && styles.labelBlock ); const classes = cx( - styles.buttonView( { isDeselectable, isIcon, isPressed, size } ), + styles.buttonView( { + isDeselectable, + isIcon, + isMultiple, + isPressed, + size, + } ), className ); - const buttonOnClick = () => { - if ( isDeselectable && isPressed ) { - otherContextProps.setState( undefined ); - } else { - otherContextProps.setState( value ); - } + const singleSelectButtonProps = { + 'aria-pressed': isPressed, + onClick: () => + otherContextProps.setState( isPressed ? undefined : value ), }; return ( @@ -97,11 +104,10 @@ function ToggleGroupControlOptionBase( { isDeselectable ? (