fix(switch):set disabled for loading status & set cursor as not-allowed (#13219)

This commit is contained in:
jojoLockLock 2018-11-21 11:01:18 +08:00 committed by 偏右
parent 2bf0fadb11
commit 171e36680f
3 changed files with 10 additions and 4 deletions

View File

@ -42,7 +42,8 @@ exports[`renders ./components/switch/demo/loading.md correctly 1`] = `
<div>
<button
aria-checked="true"
class="ant-switch-loading ant-switch ant-switch-checked"
class="ant-switch-loading ant-switch ant-switch-checked ant-switch-disabled"
disabled=""
role="switch"
type="button"
>
@ -70,7 +71,8 @@ exports[`renders ./components/switch/demo/loading.md correctly 1`] = `
<br />
<button
aria-checked="false"
class="ant-switch-small ant-switch-loading ant-switch"
class="ant-switch-small ant-switch-loading ant-switch ant-switch-disabled"
disabled=""
role="switch"
type="button"
>

View File

@ -48,7 +48,7 @@ export default class Switch extends React.Component<SwitchProps, {}> {
}
render() {
const { prefixCls, size, loading, className = '' } = this.props;
const { prefixCls, size, loading, className = '', disabled } = this.props;
const classes = classNames(className, {
[`${prefixCls}-small`]: size === 'small',
[`${prefixCls}-loading`]: loading,
@ -64,6 +64,7 @@ export default class Switch extends React.Component<SwitchProps, {}> {
<RcSwitch
{...omit(this.props, ['loading'])}
className={classes}
disabled={disabled || loading}
ref={this.saveSwitch}
loadingIcon={loadingIcon}
/>

View File

@ -153,8 +153,11 @@
&-loading,
&-disabled {
pointer-events: none;
cursor: not-allowed;
opacity: @switch-disabled-opacity;
* {
cursor: not-allowed;
}
}
}