Skip to content

Commit

Permalink
feat(ARIA): incorporate checkbox, radio, and switch roles into …
Browse files Browse the repository at this point in the history
…their respective control box components (#826)
  • Loading branch information
cheton authored Feb 7, 2024
1 parent 39eb74c commit 0a7399a
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 120 deletions.
16 changes: 3 additions & 13 deletions packages/react/src/checkbox/CheckboxControlBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ const CheckboxControlBox = forwardRef((
md: '4x',
sm: '3x',
}[size];
const icon = !!indeterminate
? <IconIndeterminate size={iconSize} />
: <IconChecked size={iconSize} />;
const inputType = 'checkbox';
const getCheckboxControlBoxSelector = (pseudos) => {
return `input[type="${inputType}"]` + ensureString(pseudos) + ' + &';
Expand Down Expand Up @@ -228,20 +225,13 @@ const CheckboxControlBox = forwardRef((

return (
<Box
aria-hidden={ariaAttr(true)}
aria-hidden={ariaAttr(true)} // aria-hidden="true" must be applied to all the images simulating a checkbox
role="checkbox"
sx={[sx, ...ensureArray(sxProp)]}
{...styleProps}
{...rest}
>
<Box
zIndex="-1"
position="absolute"
top="0"
bottom="0"
left="0"
right="0"
/>
{icon}
{!!indeterminate ? <IconIndeterminate size={iconSize} /> : <IconChecked size={iconSize} />}
</Box>
);
});
Expand Down
Loading

0 comments on commit 0a7399a

Please sign in to comment.