Skip to content

Commit d2054f1

Browse files
committed
fix(Radio): only add tabIndex to Radio instead of all child of Group
1 parent 499f581 commit d2054f1

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

docs/radio/demo/useWithGrid.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class ControlApp extends React.Component {
6969
<Radio value="strawberry" onClick={this.onClick} >Strawberry</Radio>
7070
</Col>
7171
</Row>
72+
<Row>Just simple context</Row>
7273
</RadioGroup>
7374
</div>
7475
);

src/radio/radio-group.jsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,20 @@ class RadioGroup extends Component {
188188
(index === 0 && !this.state.value) || checked ? 0 : -1;
189189
const childrtl =
190190
child.props.rtl === undefined ? rtl : child.props.rtl;
191-
return React.cloneElement(
192-
child,
193-
child.props.tabIndex === undefined
194-
? {
195-
checked,
196-
tabIndex,
197-
rtl: childrtl,
198-
}
199-
: { checked, rtl: childrtl }
200-
);
191+
if (
192+
child.type &&
193+
child.type.displayName === 'Config(Radio)'
194+
) {
195+
return React.cloneElement(child, {
196+
checked,
197+
tabIndex,
198+
rtl: childrtl,
199+
});
200+
}
201+
return React.cloneElement(child, {
202+
checked,
203+
rtl: childrtl,
204+
});
201205
}
202206
);
203207
} else {

0 commit comments

Comments
 (0)