-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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(nuxt): preserve old vnode when leaving nested route #21823
Conversation
Run & review this pull request in StackBlitz Codeflow. |
839508e
to
ac2e7d4
Compare
@antfu Let me know if you can think of any more tests or edge cases to cover. |
Co-authored-by: Horu <73709188+HigherOrderLogic@users.noreply.github.com>
const route = {} as RouteLocation | ||
for (const key in props.route) { | ||
(route as any)[key] = computed(() => previousKey === props.renderKey ? props.route[key as keyof RouteLocationNormalizedLoaded] : previousRoute[key as keyof RouteLocationNormalizedLoaded]) | ||
} | ||
|
||
provide(PageRouteSymbol, reactive(route)) |
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.
Just an idea, I am a bit worried about too many computed and effects created for this. Maybe just a defineProperty getter would do? The calculation is simple, we probably don't need computed
dirty check logic.
const route = {} as RouteLocation
for (const key in props.route) {
Object.defineProperty(route, key, { get: () => ... })
}
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.
As the object we access are reactive, it will make the getter tracked on usage (reactivity will be inherited)
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.
Let's do it π
This reverts commit 51bd68d.
I'm not sure how to reproduce in a minimal way, but this PR appears to have caused my app to stop working properly. |
π Linked issue
resolves #20798
resolves #21417
resolves #21798
β Type of change
π Description
Thjs handles a couple of extra suspense cases:
I think some of these really should be handled by the router, but for now this should make things more synchronous and reduce flickers/flashes/out-of-date state between route/layout transitions.
π Checklist