Skip to content

Commit

Permalink
Support accessibleWhenDisabled for ratio option items
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Jul 16, 2024
1 parent ea67533 commit 62959f0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function ToggleGroupControlOptionBase(
</button>
) : (
<Ariakit.Radio
accessibleWhenDisabled
disabled={ disabled }
render={
<button
Expand All @@ -153,7 +154,11 @@ function ToggleGroupControlOptionBase(
if ( event.defaultPrevented ) {
return;
}
toggleGroupControlContext.setValue( value );
if ( ! disabled ) {
toggleGroupControlContext.setValue(
value
);
}
} }
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,28 @@ export const buttonView = ( {
border: 0;
}
&[disabled] {
opacity: 0.4;
&[disabled],
&[aria-disabled='true'] {
cursor: default;
${ ButtonContentView } {
opacity: 0.4;
}
/**
* Show an additional focus ring for disabled radio items, since the
* indicator won't follow keyboard focus. This is not an issue for non-radio
* items, since the backdrop is already decoupled from keyboard focus.
*/
&[role='radio']:focus-visible::after {
position: absolute;
content: '';
/* y-axis inset matches the border width for good sub-pixel alignment */
inset: var( --wp-admin-border-width-focus ) 4px;
border-radius: 2px;
outline: var( --wp-admin-border-width-focus ) solid
${ COLORS.theme.accent };
}
}
&:active {
Expand Down

0 comments on commit 62959f0

Please sign in to comment.