ant-design icon indicating copy to clipboard operation
ant-design copied to clipboard

fix(Spin): not close Spin immediately when using delay

Open 3Alan opened this issue 2 years ago • 5 comments

[中文版模板 / Chinese template]

🤔 This is a ...

  • [ ] New feature
  • [x] Bug fix
  • [ ] Site / documentation update
  • [ ] Demo update
  • [ ] Component style update
  • [ ] TypeScript definition update
  • [ ] Bundle size optimization
  • [ ] Performance optimization
  • [ ] Enhancement feature
  • [ ] Internationalization
  • [ ] Refactoring
  • [ ] Code style optimization
  • [ ] Test Case
  • [ ] Branch merge
  • [ ] Workflow
  • [ ] Other (about what?)

🔗 Related issue link

💡 Background and solution

Spin 组件的延迟效果当 loading 为 false 时应该立即关闭,当前还需等待 delay 后才会关闭

https://ant.design/components/spin-cn#components-spin-demo-delayanddebounce

📝 Changelog

Language Changelog
🇺🇸 English fix not close Spin immediately when using delay
🇨🇳 Chinese 修复当设置 delay 时,Spin 没有立即关闭的问题

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • [x] Doc is updated/provided or not needed
  • [x] Demo is updated/provided or not needed
  • [x] TypeScript definition is updated/provided or not needed
  • [x] Changelog is provided or not needed

3Alan avatar Jan 31 '23 06:01 3Alan

github-actions[bot] avatar Jan 31 '23 06:01 github-actions[bot]

会不会这就是预期效果?

yoyo837 avatar Jan 31 '23 06:01 yoyo837

我理解的是delay仅作用于显示的时候。比如我现在有一个接口请求并设置delay=1秒,故网络请求小于1s时不显示loading。但是当网络请求为2秒时,我在第2秒时设置spining为false(这时接口已经请求完应该关闭loading),但是由于关闭也有延迟导致最终是在第3(2+ 1(delay))秒时loading才消失

3Alan avatar Jan 31 '23 07:01 3Alan

我理解的是delay仅作用于显示的时候。比如我现在有一个接口请求并设置delay=1秒,故网络请求小于1s时不显示loading。但是当网络请求为2秒时,我在第2秒时设置spining为false(这时接口已经请求完应该关闭loading),但是由于关闭也有延迟导致最终是在第3(2+ 1(delay))秒时loading才消失

你是对的

yoyo837 avatar Jan 31 '23 08:01 yoyo837

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:

Coverage data is based on head (170b823) compared to base (2a168b1). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #40475   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          604       604           
  Lines        10273     10275    +2     
  Branches      2782      2783    +1     
=========================================
+ Hits         10273     10275    +2     
Impacted Files Coverage Δ
components/spin/index.tsx 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Jan 31 '23 08:01 codecov[bot]

赞同👍,建议再补充一下测试用例。

Wxh16144 avatar Feb 07 '23 03:02 Wxh16144

测试用例已补充

3Alan avatar Feb 07 '23 04:02 3Alan