Skip to content

Commit

Permalink
fix(switch):set disabled for loading status & set cursor as not-allow…
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoLockLock authored and afc163 committed Nov 21, 2018
1 parent 2bf0fad commit 171e366
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions components/switch/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
Expand Down Expand Up @@ -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"
>
Expand Down
3 changes: 2 additions & 1 deletion components/switch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}
/>
Expand Down
5 changes: 4 additions & 1 deletion components/switch/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@

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

Expand Down

0 comments on commit 171e366

Please sign in to comment.