Repository navigation
fix(nuxt): preserve old vnode when leaving nested route - #21823
Conversation
|
|
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 <[email protected]>
| 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.
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.
As the object we access are reactive, it will make the getter tracked on usage (reactivity will be inherited)
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