Skip to content

fix portal render timing to preserve transition enter classes#3859

Open
daresTheDevil wants to merge 1 commit intotailwindlabs:1.xfrom
daresTheDevil:fix/vue-portal-transition-3456
Open

fix portal render timing to preserve transition enter classes#3859
daresTheDevil wants to merge 1 commit intotailwindlabs:1.xfrom
daresTheDevil:fix/vue-portal-transition-3456

Conversation

@daresTheDevil
Copy link
Copy Markdown

@daresTheDevil daresTheDevil commented Mar 21, 2026

Fixes: #3456

What

Portal's ready ref was initialized as ref(false) and flipped to true in onMounted, 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, so enterFrom classes never get applied and enter transitions are invisible.

Fix

Initialize ready as ref(env.isClient) instead of ref(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 server env.isClient is false, preserving the SSR hydration safety that the deferred render was originally added for (6444e01).

The onMounted callback is kept as a no-op safety net.

Test

Added a regression test that mounts a TransitionRoot > Portal and verifies the portal content renders on the same tick as the transition toggle.

Note

The same ref(false) pattern exists on main. This fix targets 1.x but should be forward-ported.


Credit to @shengslogar for isolating the regression to the ready ref change in portal.ts introduced in v1.7.17.

…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
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 21, 2026

@daresTheDevil is attempting to deploy a commit to the Tailwind Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant