File tree Expand file tree Collapse file tree 3 files changed +55
-1
lines changed Expand file tree Collapse file tree 3 files changed +55
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @remix-run/router " : patch
3
+ ---
4
+
5
+ [ REMOVE] Fix additional edge case for #10674
Original file line number Diff line number Diff line change @@ -10073,6 +10073,54 @@ describe("a router", () => {
10073
10073
expect(t.router.state.fetchers.get(key)?.state).toBe("idle");
10074
10074
expect(t.router.state.fetchers.get(key)?.data).toBeUndefined();
10075
10075
});
10076
+
10077
+ it("ignores submission redirect navigation if preceded by a normal GET navigation (w/o loaders)", async () => {
10078
+ let key = "key";
10079
+ let t = setup({
10080
+ routes: [
10081
+ {
10082
+ path: "",
10083
+ id: "root",
10084
+ children: [
10085
+ {
10086
+ path: "/",
10087
+ id: "index",
10088
+ },
10089
+ {
10090
+ path: "/foo",
10091
+ id: "foo",
10092
+ action: true,
10093
+ },
10094
+ {
10095
+ path: "/bar",
10096
+ id: "bar",
10097
+ },
10098
+ {
10099
+ path: "/baz",
10100
+ id: "baz",
10101
+ },
10102
+ ],
10103
+ },
10104
+ ],
10105
+ });
10106
+ let A = await t.fetch("/foo", key, {
10107
+ formMethod: "post",
10108
+ formData: createFormData({ key: "value" }),
10109
+ });
10110
+ await t.navigate("/bar");
10111
+
10112
+ // This redirect should be ignored
10113
+ await A.actions.foo.redirect("/baz");
10114
+ expect(t.router.state.fetchers.get(key)?.state).toBe("idle");
10115
+
10116
+ expect(t.router.state).toMatchObject({
10117
+ navigation: IDLE_NAVIGATION,
10118
+ location: { pathname: "/bar" },
10119
+ loaderData: {},
10120
+ });
10121
+ expect(t.router.state.fetchers.get(key)?.state).toBe("idle");
10122
+ expect(t.router.state.fetchers.get(key)?.data).toBeUndefined();
10123
+ });
10076
10124
});
10077
10125
10078
10126
describe(`
Original file line number Diff line number Diff line change @@ -1500,6 +1500,8 @@ export function createRouter(init: RouterInit): Router {
1500
1500
( matchesToLoad && matchesToLoad . some ( ( m ) => m . route . id === routeId ) )
1501
1501
) ;
1502
1502
1503
+ pendingNavigationLoadId = ++ incrementingLoadId ;
1504
+
1503
1505
// Short circuit if we have no loaders to run
1504
1506
if ( matchesToLoad . length === 0 && revalidatingFetchers . length === 0 ) {
1505
1507
let updatedFetchers = markFetchRedirectsDone ( ) ;
@@ -1541,7 +1543,6 @@ export function createRouter(init: RouterInit): Router {
1541
1543
} ) ;
1542
1544
}
1543
1545
1544
- pendingNavigationLoadId = ++ incrementingLoadId ;
1545
1546
revalidatingFetchers . forEach ( ( rf ) => {
1546
1547
if ( fetchControllers . has ( rf . key ) ) {
1547
1548
abortFetcher ( rf . key ) ;
You can’t perform that action at this time.
0 commit comments