Browse Source

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

pull/13239/head
jojoLockLock 6 years ago
committed by 偏右
parent
commit
171e36680f
  1. 6
      components/switch/__tests__/__snapshots__/demo.test.js.snap
  2. 3
      components/switch/index.tsx
  3. 5
      components/switch/style/index.less

6
components/switch/__tests__/__snapshots__/demo.test.js.snap

@ -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"
>

3
components/switch/index.tsx

@ -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}
/>

5
components/switch/style/index.less

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

Loading…
Cancel
Save