Skip to content

Commit

Permalink
refactor(button): can't be clicked in loading status (#1752)
Browse files Browse the repository at this point in the history
* fix: Button can't be clicked when loading

* docs: 增加 changelog

* fix: 修改 changelog 格式

Co-authored-by: 07akioni <[email protected]>
  • Loading branch information
ManiaJack and 07akioni authored Dec 12, 2021
1 parent 0c6718d commit 577eda4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Breaking Changes

- `n-button` can no longer be clicked under `loading` status, closes [#1628](https://github.com/TuSimple/naive-ui/issues/1628).

### Fixes

- Fix `n-alert`'s `header` slot unable to display normally.
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Breaking Changes

- `b-button``loading` 状态不可再被点击,关闭 [#1628](https://github.com/TuSimple/naive-ui/issues/1628)

### Fixes

- 修复 `n-alert``header` slot 无法正常显示
Expand Down
3 changes: 2 additions & 1 deletion src/button/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const Button = defineComponent({
}
}
const handleClick = (e: MouseEvent): void => {
if (!props.disabled) {
if (!props.disabled && !props.loading) {
const { onClick } = props
if (onClick) call(onClick, e)
if (!props.text) {
Expand Down Expand Up @@ -509,6 +509,7 @@ const Button = defineComponent({
!this.text && this.dashed && `${mergedClsPrefix}-button--dashed`,
this.color && `${mergedClsPrefix}-button--color`,
this.secondary && `${mergedClsPrefix}-button--secondary`,
this.loading && `${mergedClsPrefix}-button--loading`,
this.ghost && `${mergedClsPrefix}-button--ghost` // required for button group border collapse
]}
tabindex={this.mergedFocusable ? 0 : -1}
Expand Down
3 changes: 3 additions & 0 deletions src/button/src/styles/button.cssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ export default c([
})
])
]),
cM('loading', {
'pointer-events': 'none'
}),
cB('base-wave', `
pointer-events: none;
top: 0;
Expand Down

0 comments on commit 577eda4

Please sign in to comment.