From d3602f67070867ecc26d20d67607b6e706572b04 Mon Sep 17 00:00:00 2001 From: Nirva-Software Date: Thu, 11 Dec 2025 11:22:11 +0100 Subject: [PATCH 1/2] Fix loading state when initially matching as FOW + tests --- .../__tests__/router/lazy-discovery-test.ts | 19 +++++++++++++++++++ packages/react-router/lib/router/router.ts | 2 ++ 2 files changed, 21 insertions(+) diff --git a/packages/react-router/__tests__/router/lazy-discovery-test.ts b/packages/react-router/__tests__/router/lazy-discovery-test.ts index 93b73e719f..6d5577bee1 100644 --- a/packages/react-router/__tests__/router/lazy-discovery-test.ts +++ b/packages/react-router/__tests__/router/lazy-discovery-test.ts @@ -999,9 +999,18 @@ describe("Lazy Route Discovery (Fog of War)", () => { expect(router.state.initialized).toBe(false); expect(router.state.matches.map((m) => m.route.id)).toEqual(["parent"]); + expect(router.state.navigation).toMatchObject({ + state: "loading", + location: { pathname: "/parent/child" }, + }); + loaderDfd.resolve("PARENT"); expect(router.state.initialized).toBe(false); expect(router.state.matches.map((m) => m.route.id)).toEqual(["parent"]); + expect(router.state.navigation).toMatchObject({ + state: "loading", + location: { pathname: "/parent/child" }, + }); childrenDfd.resolve([ { @@ -1012,8 +1021,17 @@ describe("Lazy Route Discovery (Fog of War)", () => { ]); expect(router.state.initialized).toBe(false); expect(router.state.matches.map((m) => m.route.id)).toEqual(["parent"]); + expect(router.state.navigation).toMatchObject({ + state: "loading", + location: { pathname: "/parent/child" }, + }); childLoaderDfd.resolve("CHILD"); + + expect(router.state.navigation).toMatchObject({ + state: "loading", + location: { pathname: "/parent/child" }, + }); await tick(); expect(router.state.initialized).toBe(true); expect(router.state.location.pathname).toBe("/parent/child"); @@ -1025,6 +1043,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { "parent", "child", ]); + expect(router.state.navigation).toMatchObject(IDLE_NAVIGATION); }); it("discovers routes during initial SPA renders when a splat route matches", async () => { diff --git a/packages/react-router/lib/router/router.ts b/packages/react-router/lib/router/router.ts index 42894b4017..815ad32054 100644 --- a/packages/react-router/lib/router/router.ts +++ b/packages/react-router/lib/router/router.ts @@ -2087,6 +2087,8 @@ export function createRouter(init: RouterInit): Router { flushSync, }, ); + } else if (initialMatchesIsFOW) { + updateState({ navigation: loadingNavigation }, { flushSync }); } let discoverResult = await discoverRoutes( From 7ee7628284b3f1fdb5d99d4eff70ff359f1f7215 Mon Sep 17 00:00:00 2001 From: Nirva-Software Date: Thu, 11 Dec 2025 12:07:24 +0100 Subject: [PATCH 2/2] sign cla --- contributors.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.yml b/contributors.yml index c98ad34092..e4aeef7aa6 100644 --- a/contributors.yml +++ b/contributors.yml @@ -298,6 +298,7 @@ - nichtsam - nikeee - nilubisan +- Nirva-Software - Nismit - nnhjs - noisypigeon