Skip to content

Commit

Permalink
fix: fix up default history push behavior on redirects (#9117)
Browse files Browse the repository at this point in the history
* fix: fix up default history push behavior on redirects

* add changeset

* cleanup

* Handle historyAction=REPLACE for normal redirects

* Bump bundle

* properly handle redirects using origin replace

* Update comment

* Revert bundle bump
  • Loading branch information
brophdawg11 authored Aug 9, 2022
1 parent c21e38e commit 5a56b5c
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 58 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-olives-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/router": patch
---

fix: fix default redirect push/replace behavior (#9117)
24 changes: 15 additions & 9 deletions packages/react-router-dom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,15 @@ type SetURLSearchParams = (
navigateOpts?: NavigateOptions
) => void;

type SubmitTarget =
| HTMLFormElement
| HTMLButtonElement
| HTMLInputElement
| FormData
| URLSearchParams
| { [name: string]: string }
| null;

/**
* Submits a HTML `<form>` to the server without reloading the page.
*/
Expand All @@ -784,14 +793,7 @@ export interface SubmitFunction {
* Note: When using a `<button>` its `name` and `value` will also be
* included in the form data that is submitted.
*/
target:
| HTMLFormElement
| HTMLButtonElement
| HTMLInputElement
| FormData
| URLSearchParams
| { [name: string]: string }
| null,
target: SubmitTarget,

/**
* Options that override the `<form>`'s own attributes. Required when
Expand Down Expand Up @@ -888,7 +890,11 @@ let fetcherId = 0;

export type FetcherWithComponents<TData> = Fetcher<TData> & {
Form: ReturnType<typeof createFetcherForm>;
submit: ReturnType<typeof useSubmitImpl>;
submit: (
target: SubmitTarget,
// Fetchers cannot replace because they are not navigation events
options?: Omit<SubmitOptions, "replace">
) => void;
load: (href: string) => void;
};

Expand Down
Loading

0 comments on commit 5a56b5c

Please sign in to comment.