From 38410d70acd6cff54d5c2f6ccc3204f0eebd2a81 Mon Sep 17 00:00:00 2001 From: Manuel Schiller Date: Thu, 24 Apr 2025 20:39:17 +0200 Subject: [PATCH 1/2] fix: pending component handling for initial load also sets match status to 'succes' only after lazy loaded components were loaded --- packages/router-core/src/router.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts index cdc2c1201d9..f41b47fe2f9 100644 --- a/packages/router-core/src/router.ts +++ b/packages/router-core/src/router.ts @@ -2274,10 +2274,6 @@ export class RouterCore< return !!(allPreload && !this.state.matches.find((d) => d.id === matchId)) } - if (!this.isServer && !this.state.matches.length) { - triggerOnReady() - } - const handleRedirectAndNotFound = (match: AnyRouteMatch, err: any) => { if (isResolvedRedirect(err)) { if (!err.reloadDocument) { @@ -2383,7 +2379,9 @@ export class RouterCore< onReady && !this.isServer && !resolvePreload(matchId) && - (route.options.loader || route.options.beforeLoad) && + (route.options.loader || + route.options.beforeLoad || + routeNeedsPreload(route)) && typeof pendingMs === 'number' && pendingMs !== Infinity && (route.options.pendingComponent ?? @@ -2668,6 +2666,10 @@ export class RouterCore< loaderData, }) + // Last but not least, wait for the the components + // to be preloaded before we resolve the match + await route._componentsPromise + updateMatch(matchId, (prev) => ({ ...prev, error: undefined, @@ -2710,10 +2712,6 @@ export class RouterCore< router: this, match: this.getMatch(matchId)!, }) - - // Last but not least, wait for the the components - // to be preloaded before we resolve the match - await route._componentsPromise } catch (err) { updateMatch(matchId, (prev) => ({ ...prev, From 6022972db9b0900763e1a084b30f8e4f4a5b6f6b Mon Sep 17 00:00:00 2001 From: Manuel Schiller Date: Thu, 24 Apr 2025 23:00:29 +0200 Subject: [PATCH 2/2] fix: solid scroll restoration --- packages/solid-router/src/Transitioner.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/solid-router/src/Transitioner.tsx b/packages/solid-router/src/Transitioner.tsx index 385ed736cd1..51112e3bbc5 100644 --- a/packages/solid-router/src/Transitioner.tsx +++ b/packages/solid-router/src/Transitioner.tsx @@ -31,9 +31,9 @@ export function Transitioner() { const previousIsPagePending = usePrevious(isPagePending) if (!router.isServer) { - router.startTransition = (fn: () => void) => { + router.startTransition = async (fn: () => void | Promise) => { setIsTransitioning(true) - fn() + await fn() setIsTransitioning(false) } }