Skip to content
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

<Suspense> + <Transition> means mounted() runs too early #5844

Closed
danielroe opened this issue May 1, 2022 · 8 comments · Fixed by #9388
Closed

<Suspense> + <Transition> means mounted() runs too early #5844

danielroe opened this issue May 1, 2022 · 8 comments · Fixed by #9388
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working scope: suspense scope: transition

Comments

@danielroe
Copy link
Member

danielroe commented May 1, 2022

Version

3.2.33

Reproduction link

Steps to reproduce

Click the Toggle component button in the reproduction, and observe that a template ref is null rather than defined.

What is expected?

I expect the behaviour with suspense to be the same as the behaviour without suspense.

What is actually happening?

<Suspense> means that the mounted() hook runs before the elements are present in the DOM.

@andysay
Copy link

andysay commented May 17, 2022

any update?

@michaelpumo
Copy link

michaelpumo commented Oct 25, 2022

I also witnessed this issue in Nuxt 3.

On hard load I can retrieve the DOM element via ref and acquire its size using getBoundingClientRect() but when navigating between routes (on the client), the onMounted() appears to run before the DOM is ready and present.

Minimal reproduction:
https://stackblitz.com/edit/nuxt-starter-xssyqg?file=pages%2Findex.vue

This is something to do with transitions.

In my mind, this is a pretty serious bug as at the moment we're having to use setTimeout() hacks in onMounted() in order to ensure the DOM element is retrievable and usable. The timing of this is directly linked to the page transition time.

@richgcook
Copy link

It's causing a lot of issues and having to rely on a timeout, which is irregular, is too costly.

@sodatea sodatea added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. and removed 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Mar 27, 2023
@maximilliangeorge
Copy link

There's a PR up that claims to fix this issue.
#5952

However, it's been pretty stale for months now. Hope to see it merged soon.

@Triloworld
Copy link

Confirm as comment: #5952 (comment)
Is deal breaker . We entirely disable animation and this stop people from migration to new version of framework - it is disabled by this issue on main repo from 3.0.0-rc.13 onwards by default (https://github.com/nuxt/nuxt/releases/tag/v3.0.0-rc.13 and nuxt/framework#8436). Waiting now whole year for pr to be merge.
Right now there is 43 other issues related to page transition feature: https://github.com/nuxt/nuxt/issues?q=is%3Aissue+is%3Aopen+transition
Whole transition feature on nuxt 3 is now depending on this issue to be resolved.

@Triloworld
Copy link

@yyx990803 Can you look on this ? Will unblock more people to upgrade Vue 3 and resolve plenty issue. PR exist and issue is mark as important.

@jd-solanki
Copy link

Linking #8967

@pikax
Copy link
Member

pikax commented Oct 12, 2023

Just to give an update on this, I've created a PR #9388 aimed to fix this

Vue.SFC.Playground.-.Personal.-.Microsoft.Edge.2023-10-12.20-59-54.mp4

It's working, but since this is touching Suspense, I would expect more scrutiny while reviewing, because it can be very easy for this PR break things downstream.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working scope: suspense scope: transition
Projects
None yet