-
Notifications
You must be signed in to change notification settings - Fork 7.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: spinner may stop playing animation after dismiss #5365
Conversation
|
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
packages/@core/ui-kit/shadcn-ui/src/components/spinner/spinner.vueOops! Something went wrong! :( ESLint: 9.17.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/node_modules/@vben/eslint-config/dist/index.mjs' imported from /eslint.config.mjs WalkthroughThe pull request introduces changes to the Changes
Assessment against linked issues
Suggested Reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (9)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/@core/ui-kit/shadcn-ui/src/components/spinner/spinner.vue (1)
Line range hint
28-42
: Consider adding a safeguard for rapid state changes.The current implementation might lead to inconsistent states if the
spinning
prop toggles rapidly. Consider clearing both state flags when spinning becomes false:watch( () => props.spinning, (show) => { if (!show) { showSpinner.value = false; + renderSpinner.value = false; clearTimeout(timer.value); return; }
This ensures the animation stops immediately when dismissed, preventing any lingering animations.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/@core/ui-kit/shadcn-ui/src/components/spinner/spinner.vue
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Test (windows-latest)
- GitHub Check: Check (windows-latest)
- GitHub Check: Test (ubuntu-latest)
- GitHub Check: Lint (windows-latest)
- GitHub Check: Check (ubuntu-latest)
- GitHub Check: Lint (ubuntu-latest)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: post-update (windows-latest)
- GitHub Check: post-update (ubuntu-latest)
🔇 Additional comments (3)
packages/@core/ui-kit/shadcn-ui/src/components/spinner/spinner.vue (3)
Line range hint
28-29
: LGTM! Good simplification of the loading logic.Removing the unnecessary performance timing and introducing
renderSpinner
ref provides cleaner state management for the animation.Also applies to: 31-31
76-77
: Good fix for the animation control!The dynamic class binding using
renderSpinner
ensures the animation stops when the spinner is dismissed, which should reduce unnecessary CPU usage. The base styles remain intact while the animation classes are toggled appropriately.
Line range hint
28-42
: Verify the fix resolves the CPU usage issue.The implementation looks good and should fix the spinner animation issue. To verify:
- The animation now stops properly on dismiss through
renderSpinner
- CPU usage should decrease when spinner is hidden
Please test the following scenarios:
- Rapid toggling of the spinner
- Long-running spinner followed by dismiss
- Multiple spinners on the same page
Would you like me to create a test suite covering these scenarios?
Also applies to: 76-77
Description
修复Spinner组件在未显示时仍然播放动画的问题。
该问题将导致即使页面处于闲置状态,后台Dom数量不能稳定且Cpu占用率也没有维持在应有的低水平
该修复方案仅仅在不显示Spinner时暂停了动画,没有改变dom结构。
fix: #5318
Type of change
Please delete options that are not relevant.
pnpm-lock.yaml
unless you introduce a new test example.Checklist
pnpm run docs:dev
command.pnpm test
.feat:
,fix:
,perf:
,docs:
, orchore:
.Summary by CodeRabbit
paused
class.paused
class to control animation playback.