diff --git a/integration/transition-test.ts b/integration/transition-test.ts index 62a89060aeb..62e18d63644 100644 --- a/integration/transition-test.ts +++ b/integration/transition-test.ts @@ -152,6 +152,44 @@ test.describe("rendering", () => { ); } `, + + "app/routes/parent.jsx": js` + import { Outlet, useLoaderData } from "@remix-run/react"; + + let count = 0; + export const loader = async ({ request }) => { + return { count: ++count }; + }; + + export default function Parent() { + const data = useLoaderData(); + return ( +
+
{data.count}
+ +
+ ); + } + `, + + "app/routes/parent/child.jsx": js` + import { redirect } from "@remix-run/node"; + import { useFetcher} from "@remix-run/react"; + + export const action = async ({ request }) => { + return redirect("/parent"); + }; + + export default function Child() { + const fetcher = useFetcher(); + + return ( + + + + ); + } + `, }, }); @@ -248,4 +286,13 @@ test.describe("rendering", () => { await app.clickSubmitButton("/gh-1691"); expect(await app.getHtml("span")).toMatch("idle"); }); + + test("fetcher action redirects re-call parent loaders", async ({ page }) => { + let app = new PlaywrightFixture(appFixture, page); + await app.goto("/parent/child"); + expect(await app.getHtml("#parent")).toMatch("1"); + + await app.clickElement("#fetcher-submit-redirect"); + expect(await app.getHtml("#parent")).toMatch("2"); + }); }); diff --git a/package.json b/package.json index d3c2de53baf..2df928b512a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test:integration": "playwright test --config ./integration/playwright.config.ts", "pretest:integration": "rollup -c", "posttest:integration": "rimraf ./.tmp/integration", - "bug-report-test": "playwright test --config ./integration/jest.config.ts integration/bug-report-test.ts", + "bug-report-test": "playwright test --config ./integration/playwright.config.ts integration/bug-report-test.ts", "playground:new": "node ./scripts/playground/new.js", "version": "node ./scripts/version.js", "watch": "rollup -c -w", diff --git a/packages/remix-react/__tests__/transition-test.tsx b/packages/remix-react/__tests__/transition-test.tsx index 91244efafff..005cc31c2f6 100644 --- a/packages/remix-react/__tests__/transition-test.tsx +++ b/packages/remix-react/__tests__/transition-test.tsx @@ -1408,6 +1408,8 @@ describe("fetcher redirects", () => { "type": "done", } `); + // Root loader should be re-called after fetchActionRedirect + expect(t.rootLoaderMock.calls.length).toBe(1); }); }); diff --git a/packages/remix-react/transition.ts b/packages/remix-react/transition.ts index aa35d2790da..219836e6529 100644 --- a/packages/remix-react/transition.ts +++ b/packages/remix-react/transition.ts @@ -1536,6 +1536,7 @@ function filterMatchesToLoad( // mutation, reload for fresh data state.transition.type === "actionReload" || state.transition.type === "actionRedirect" || + state.transition.type === "fetchActionRedirect" || // clicked the same link, resubmitted a GET form createHref(url) === createHref(state.location) || // search affects all loaders