diff --git a/components/switch/index.jsx b/components/switch/index.jsx index 879da0af6..71474fff7 100644 --- a/components/switch/index.jsx +++ b/components/switch/index.jsx @@ -18,7 +18,7 @@ const Switch = { disabled: PropTypes.bool, checkedChildren: PropTypes.any, unCheckedChildren: PropTypes.any, - tabIndex: PropTypes.number, + tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), checked: PropTypes.bool, defaultChecked: PropTypes.bool, autoFocus: PropTypes.bool, diff --git a/components/vc-switch/PropTypes.js b/components/vc-switch/PropTypes.js index 7f39e8ec0..a7a764634 100644 --- a/components/vc-switch/PropTypes.js +++ b/components/vc-switch/PropTypes.js @@ -8,7 +8,7 @@ export const switchPropTypes = { // onChange: PropTypes.func, // onMouseUp: PropTypes.func, // onClick: PropTypes.func, - tabIndex: PropTypes.number, + tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), checked: PropTypes.bool.def(false), defaultChecked: PropTypes.bool.def(false), autoFocus: PropTypes.bool.def(false), diff --git a/components/vc-switch/Switch.jsx b/components/vc-switch/Switch.jsx index 4ec1b4ca9..a0990f884 100644 --- a/components/vc-switch/Switch.jsx +++ b/components/vc-switch/Switch.jsx @@ -79,7 +79,7 @@ export default { }, }, render() { - const { prefixCls, disabled, loadingIcon, ...restProps } = getOptionProps(this); + const { prefixCls, disabled, loadingIcon, tabIndex, ...restProps } = getOptionProps(this); const checked = this.stateChecked; const switchClassName = { [prefixCls]: true, @@ -99,6 +99,7 @@ export default { role: 'switch', 'aria-checked': checked, disabled, + tabIndex, }, class: switchClassName, ref: 'refSwitchNode',