fix(Button):the wave animation bug of loading state switching🌊 #6895
+2
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Antd Vue Version
4.0.1
BUG描述
修复按钮loading状态切换的动画bug。当按钮多次切换到loading状态之后,点击按钮,会发现按钮的波浪动画颜色很深(其实是建立了多个wave的动画元素)
复现链接
https://codesandbox.io/s/antd-vue-4-0-button-wave-bug-cftvrz?file=/src/demo.vue
复现步骤
click!click!
,等待模拟异步请求完成,loading状态切换为false。Antd Vue1
,会发现波浪动画的颜色很深,而第二个按钮不会。代码改动说明
改动的代码文件是
ant-design-vue\components\_util\wave\index.tsx
增加了
(!newV && oldV)
的判断条件。原本出现这个bug是因为当loading状态切换为true的时候(
props.disabled
也为true),会触发watch
,由于在nextTick
中判断了props.disabled
,所以不会新建wave
动画元素,但是当异步请求结束,loading状态变为false,此时也会触发watch
,但是在nextTick
中没有拦截这种情况,就导致了会新建一个wave
动画元素。多次反复之后就会新建多个wave
动画元素。所以我判断了如果loading状态从true变为false的时候,不会新建
wave
动画元素。其它问题
从正常状态切换loading状态的时候,在loading状态时点击还存在wave动画,这是否符合最初的设计?
因为我看到官网上的例子,如果一开始就是loading状态,点击的时候不会有wave动画。
在此PR中没有涉及这个问题的更改。