fix(transition): prevent enter if leave is in progress#14443
fix(transition): prevent enter if leave is in progress#14443edison1105 merged 5 commits intovuejs:mainfrom
Conversation
📝 WalkthroughWalkthroughA guard was added to the transition enter hook to prevent enter from executing when a leave transition is already in progress. An e2e test was added to verify this behavior through hook ordering and DOM state validation. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/runtime-core/__tests__/components/BaseTransition.spec.ts`:
- Around line 1245-1251: The test uses setTimeout which lets the callback run
after the test completes, so move to an awaited promise-based delay (or directly
await nextTick if sufficient) so the test waits for the toggle change and
assertions to run synchronously; specifically set toggle.value = true, await the
appropriate async resolution (e.g., await nextTick() or await new Promise(res =>
setTimeout(res))), then assert
expect(hooks.join('-')).toBe('beforeEnter-beforeLeave-leave-afterLeave')—also
replace the non-standard .eq() matcher with .toBe() and ensure you're awaiting
nextTick() after setting toggle.value to properly flush updates.
packages/runtime-core/__tests__/components/BaseTransition.spec.ts
Outdated
Show resolved
Hide resolved
| }, | ||
|
|
||
| enter(el) { | ||
| if (el[isLeavingKey]) return |
There was a problem hiding this comment.
Thank you very much. I’ve already updated it.
There was a problem hiding this comment.
Thank you for your PR. The fix is correct, but I've made some adjustments. The tests have also been switched to e2e tests because the unit tests' leave completes immediately, which is inconsistent with browser behavior.
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|

close #12091
close #12133
Link to minimal reproduction
https://play.vuejs.org/#eNrtV19vEzkQ/yqjFVITKdnkKCeh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OifuX2ACejccRyC8voH24NGJCNxKjpO+JXFLzFm4Cz7WfN1ESoujjbvql3fS4Yn7rivlYo/G/nGjJnKZ/p0+fJ7svbRhiDQ==
Problem
If the state is toggled back to
falseduringbeforeEnter,<Transition>hooks can run in an unexpected order:Result
After this change, the hook sequence becomes:
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests