Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions integration/transition-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
<div id="parent">{data.count}</div>
<Outlet />
</div>
);
}
`,

"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 (
<fetcher.Form method="post">
<button id="fetcher-submit-redirect" type="submit">Submit</button>
</fetcher.Form>
);
}
`,
},
});

Expand Down Expand Up @@ -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");
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions packages/remix-react/__tests__/transition-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,8 @@ describe("fetcher redirects", () => {
"type": "done",
}
`);
// Root loader should be re-called after fetchActionRedirect
expect(t.rootLoaderMock.calls.length).toBe(1);
});
});

Expand Down
1 change: 1 addition & 0 deletions packages/remix-react/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down