fix: switch tabIndex not work

pull/1143/head
tanjinzhou 2019-08-30 12:55:45 +08:00
parent c9f1c26693
commit 0a419dac6a
3 changed files with 4 additions and 3 deletions

View File

@ -18,7 +18,7 @@ const Switch = {
disabled: PropTypes.bool, disabled: PropTypes.bool,
checkedChildren: PropTypes.any, checkedChildren: PropTypes.any,
unCheckedChildren: PropTypes.any, unCheckedChildren: PropTypes.any,
tabIndex: PropTypes.number, tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
checked: PropTypes.bool, checked: PropTypes.bool,
defaultChecked: PropTypes.bool, defaultChecked: PropTypes.bool,
autoFocus: PropTypes.bool, autoFocus: PropTypes.bool,

View File

@ -8,7 +8,7 @@ export const switchPropTypes = {
// onChange: PropTypes.func, // onChange: PropTypes.func,
// onMouseUp: PropTypes.func, // onMouseUp: PropTypes.func,
// onClick: PropTypes.func, // onClick: PropTypes.func,
tabIndex: PropTypes.number, tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
checked: PropTypes.bool.def(false), checked: PropTypes.bool.def(false),
defaultChecked: PropTypes.bool.def(false), defaultChecked: PropTypes.bool.def(false),
autoFocus: PropTypes.bool.def(false), autoFocus: PropTypes.bool.def(false),

View File

@ -79,7 +79,7 @@ export default {
}, },
}, },
render() { render() {
const { prefixCls, disabled, loadingIcon, ...restProps } = getOptionProps(this); const { prefixCls, disabled, loadingIcon, tabIndex, ...restProps } = getOptionProps(this);
const checked = this.stateChecked; const checked = this.stateChecked;
const switchClassName = { const switchClassName = {
[prefixCls]: true, [prefixCls]: true,
@ -99,6 +99,7 @@ export default {
role: 'switch', role: 'switch',
'aria-checked': checked, 'aria-checked': checked,
disabled, disabled,
tabIndex,
}, },
class: switchClassName, class: switchClassName,
ref: 'refSwitchNode', ref: 'refSwitchNode',