Skip to content

Commit

Permalink
Fix RadioGroup to support zero as a Radio value (#27906)
Browse files Browse the repository at this point in the history
  • Loading branch information
stokesman authored Jan 6, 2021
1 parent 35a94fd commit d94b354
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/components/src/radio-group/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function RadioGroup(
...radioState,
disabled,
// controlled or uncontrolled
state: checked || radioState.state,
setState: onChange || radioState.setState,
state: checked ?? radioState.state,
setState: onChange ?? radioState.setState,
};

return (
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/radio-group/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const disabled = () => {
};

const ControlledRadioGroupWithState = () => {
const [ checked, setChecked ] = useState( 'option2' );
const [ checked, setChecked ] = useState( 1 );

/* eslint-disable no-restricted-syntax */
return (
Expand All @@ -58,9 +58,9 @@ const ControlledRadioGroupWithState = () => {
checked={ checked }
onChange={ setChecked }
>
<Radio value="option1">Option 1</Radio>
<Radio value="option2">Option 2</Radio>
<Radio value="option3">Option 3</Radio>
<Radio value={ 0 }>Option 1</Radio>
<Radio value={ 1 }>Option 2</Radio>
<Radio value={ 2 }>Option 3</Radio>
</RadioGroup>
);
/* eslint-enable no-restricted-syntax */
Expand Down

0 comments on commit d94b354

Please sign in to comment.