Skip to content

Commit

Permalink
fix(Radio): only add tabIndex to Radio instead of all child of Group
Browse files Browse the repository at this point in the history
  • Loading branch information
guanpu committed Jun 12, 2019
1 parent 499f581 commit d2054f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/radio/demo/useWithGrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ControlApp extends React.Component {
<Radio value="strawberry" onClick={this.onClick} >Strawberry</Radio>
</Col>
</Row>
<Row>Just simple context</Row>
</RadioGroup>
</div>
);
Expand Down
24 changes: 14 additions & 10 deletions src/radio/radio-group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,20 @@ class RadioGroup extends Component {
(index === 0 && !this.state.value) || checked ? 0 : -1;
const childrtl =
child.props.rtl === undefined ? rtl : child.props.rtl;
return React.cloneElement(
child,
child.props.tabIndex === undefined
? {
checked,
tabIndex,
rtl: childrtl,
}
: { checked, rtl: childrtl }
);
if (
child.type &&
child.type.displayName === 'Config(Radio)'
) {
return React.cloneElement(child, {
checked,
tabIndex,
rtl: childrtl,
});
}
return React.cloneElement(child, {
checked,
rtl: childrtl,
});
}
);
} else {
Expand Down

0 comments on commit d2054f1

Please sign in to comment.