Skip to content

Commit b5974ad

Browse files
Michael JordansnowystingerLFDanLu
authored
fix(#5747): [react-aira: RadioGroup]: No tabindex/Can't keyboard focus to input until value is checked (#5755)
Looks like the default selected value in the example is an empty string, which is not the same as null. https://github.com/adobe/react-spectrum/pull/4985/files#diff-26ddea7c3bd0c2b48179af98635706a6391a01b59c936e8b497d1843a97ff202R71-R78 A more robust solution might be to validate whether the default value is one of the possible values within the radio group, but that's a bit more complicated. Co-authored-by: Robert Snow <rsnow@adobe.com> Co-authored-by: Daniel Lu <dl1644@gmail.com>
1 parent 87dbb74 commit b5974ad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/react-aria-components/docs/RadioGroup.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,15 @@ The `onChange` event is fired when the user selects a radio.
261261

262262
```tsx example
263263
function Example() {
264-
let [selected, setSelected] = React.useState('');
264+
let [selected, setSelected] = React.useState(null);
265265

266266
return (
267267
<>
268268
<MyRadioGroup label="Favorite avatar" value={selected} onChange={setSelected}>
269269
<Radio value="wizard">Wizard</Radio>
270270
<Radio value="dragon">Dragon</Radio>
271271
</MyRadioGroup>
272-
<p>You have selected: {selected}</p>
272+
<p>You have selected: {selected ?? ''}</p>
273273
</>
274274
);
275275
}

0 commit comments

Comments
 (0)