Skip to content

Commit e3bd5a6

Browse files
Fix tabindex bug (#1316)
1 parent 4ef8ebb commit e3bd5a6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.changeset/cold-hats-drive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@obosbbl/grunnmuren-react": patch
3+
---
4+
5+
Fixes an accessibility issue with the `<RadioGroup>` component, where passing `value=""` as a prop caused the radio input to get `tabindex="-1"`. Which would make it inaccessible to keyboard and screen reader users.

packages/react/src/radiogroup/radio-group.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function RadioGroup(props: RadioGroupProps) {
4242
label,
4343
isRequired,
4444
isInvalid: _isInvalid,
45+
value,
4546
...restProps
4647
} = props;
4748

@@ -52,6 +53,8 @@ function RadioGroup(props: RadioGroupProps) {
5253
return (
5354
<RACRadioGroup
5455
{...restProps}
56+
// Tabindex is set to -1 when the value is an empty string, which makes the radio input not focusable
57+
value={value === '' ? undefined : value}
5558
className={cx(className, 'flex flex-col gap-2')}
5659
isInvalid={isInvalid}
5760
isRequired={isRequired}

0 commit comments

Comments
 (0)