fix portal render timing to preserve transition enter classes#3859
Open
daresTheDevil wants to merge 1 commit intotailwindlabs:1.xfrom
Open
fix portal render timing to preserve transition enter classes#3859daresTheDevil wants to merge 1 commit intotailwindlabs:1.xfrom
daresTheDevil wants to merge 1 commit intotailwindlabs:1.xfrom
Conversation
…ndlabs#3456) Initialize portal `ready` ref eagerly on the client instead of deferring to `onMounted`. The deferred render caused a one-tick delay that raced against Vue 3.5+'s Transition lifecycle — enter-from classes never got applied because the Teleport content appeared after the transition's enter phase had already started. SSR behavior is preserved: `env.isClient` returns false when window/document are absent, so portals still defer on the server. Fixes: tailwindlabs#3456
|
@daresTheDevil is attempting to deploy a commit to the Tailwind Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes: #3456
What
Portal's
readyref was initialized asref(false)and flipped totrueinonMounted, deferring the Teleport render by one tick. With Vue 3.5+'s Transition lifecycle changes, that one-tick delay means the portal content appears after the transition's enter phase has started, soenterFromclasses never get applied and enter transitions are invisible.Fix
Initialize
readyasref(env.isClient)instead ofref(false). On the client the portal renders synchronously with the component tree, so the Teleport content exists before the parent Transition's enter phase runs. On the serverenv.isClientisfalse, preserving the SSR hydration safety that the deferred render was originally added for (6444e01).The
onMountedcallback is kept as a no-op safety net.Test
Added a regression test that mounts a
TransitionRoot > Portaland verifies the portal content renders on the same tick as the transition toggle.Note
The same
ref(false)pattern exists onmain. This fix targets1.xbut should be forward-ported.Credit to @shengslogar for isolating the regression to the
readyref change inportal.tsintroduced in v1.7.17.