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
2 changes: 1 addition & 1 deletion .github/workflows/deduplicate-lock-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
token: ${{ secrets.FORMAT_PAT }}

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
uses: actions/setup-node@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
ref: ${{ github.event.inputs.branch }}

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
uses: actions/setup-node@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
token: ${{ secrets.FORMAT_PAT }}

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
uses: actions/setup-node@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@v7

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
uses: actions/setup-node@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:

- name: Setup pnpm
if: steps.changed-files.outputs.mode == 'run'
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
if: steps.changed-files.outputs.mode == 'run'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
ref: ${{ inputs.baseBranch }}

- name: Install pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Install Node.js
uses: actions/setup-node@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-comments-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
uses: actions/setup-node@v6
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
token: ${{ secrets.FORMAT_PAT }}

- name: Install pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Install Node.js
uses: actions/setup-node@v6
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
uses: actions/checkout@v7

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
uses: actions/setup-node@v6
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
uses: actions/setup-node@v6
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
uses: actions/setup-node@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integration-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/checkout@v7

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node ${{ inputs.node_version }}
uses: actions/setup-node@v6
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ jobs:
if [ "${{ github.event_name }}" = "push" ]; then
echo "Selected integration suite: full (push to main)"
echo "type=full" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event.pull_request.head.ref }}" = "v8" ]; then
echo "Selected integration suite: dev (v8 PR)"
echo "type=dev" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event.pull_request.draft }}" = "true" ]; then
echo "Selected integration suite: base (draft PR)"
echo "type=base" >> "$GITHUB_OUTPUT"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/checkout@v7

- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
uses: pnpm/action-setup@v6.0.10

- name: Setup node
uses: actions/setup-node@v6
Expand Down
2 changes: 2 additions & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
- kklem0
- kno-raziel
- knownasilya
- kobihikri
- koojaa
- KostiantynPopovych
- KubasuIvanSakwa
Expand Down Expand Up @@ -446,6 +447,7 @@
- sunnyraindy
- sushichan044
- swalker326
- syedsohailhussain1
- szhsin
- tanayv
- thecode00
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Properly respect the `relative` option in `useSubmit`/`fetcher.submit` when resolivng the `action` path
94 changes: 94 additions & 0 deletions packages/react-router/__tests__/dom/data-browser-router-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4132,6 +4132,100 @@ function testDomRouter(
});
});

describe('submit() with relative="path"', () => {
it("submits relative to the URL for navigations", async () => {
let router = createTestRouter(
[
{
path: "inbox",
action: () => "INDEX",
children: [
{
path: "messages",
action: () => "MESSAGES",
Component() {
let actionData = useActionData();
return <p>{actionData}</p>;
},
},
{
path: "messages/:id",
Component() {
let submit = useSubmit();
return (
<button
onClick={() =>
submit(
{ a: "1" },
{ method: "post", action: "..", relative: "path" },
)
}
>
Submit
</button>
);
},
},
],
},
],
{ window: getWindow("/inbox/messages/1") },
);
render(<RouterProvider router={router} />);

fireEvent.click(screen.getByText("Submit"));
await waitFor(() => screen.getByText("MESSAGES"));
expect(router.state.location.pathname).toBe("/inbox/messages");
});

it("submits relative to the URL for fetchers", async () => {
let router = createTestRouter(
[
{
path: "inbox",
action: () => "INDEX",
children: [
{
path: "messages",
action: () => "MESSAGES",
},
{
path: "messages/:id",
Component() {
let fetcher = useFetcher();
return (
<>
<button
onClick={() =>
fetcher.submit(
{ a: "1" },
{
method: "post",
action: "..",
relative: "path",
},
)
}
>
Submit
</button>
{fetcher.data ? <p>{fetcher.data}</p> : null}
</>
);
},
},
],
},
],
{ window: getWindow("/inbox/messages/1") },
);
render(<RouterProvider router={router} />);

fireEvent.click(screen.getByText("Submit"));
await waitFor(() => screen.getByText("MESSAGES"));
});
});

describe("useSubmit/Form FormData", () => {
it("gathers form data on <Form> submissions", async () => {
let actionSpy = jest.fn();
Expand Down
2 changes: 2 additions & 0 deletions packages/react-router/lib/dom/lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,7 @@ export function useSubmit(): SubmitFunction {
await routerFetch(key, currentRouteId, options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
relative: options.relative,
formData,
body,
formMethod: options.method || (method as HTMLFormMethod),
Expand All @@ -2613,6 +2614,7 @@ export function useSubmit(): SubmitFunction {
await routerNavigate(options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
relative: options.relative,
formData,
body,
formMethod: options.method || (method as HTMLFormMethod),
Expand Down
10 changes: 4 additions & 6 deletions packages/react-router/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7680,11 +7680,11 @@ function persistAppliedTransitions(
}

function createDeferred<T = unknown>() {
let resolve: (val?: any) => Promise<void>;
let reject: (error?: Error) => Promise<void>;
let resolve!: (val?: T) => Promise<void>;
let reject!: (error?: Error) => Promise<void>;
let promise = new Promise<T>((res, rej) => {
resolve = async (val: T) => {
res(val);
resolve = async (val?: T) => {
res(val as T);
try {
await promise;
} catch {}
Expand All @@ -7698,9 +7698,7 @@ function createDeferred<T = unknown>() {
});
return {
promise,
//@ts-ignore
resolve,
//@ts-ignore
reject,
};
}
Expand Down