-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues with useFormAction/useResolvedPath for dot paths in param/splat routes #10983
Conversation
🦋 Changeset detectedLatest commit: 22a3657 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Looking at some of the existing tests, I can see the dropped splat maybe being expected for a use case such as: // Assume current url is /parent/something
<Route path="parent">
<Route path="static" element={<h1>Static</h1>} />
<Route path="*" element={<Link to="./static">Click</Link>} />
</Route> Where you want the link to go to // Assume current url is /parent/something
<Route path="parent">
<Route path="static" element={<h1>Static</h1>} />
<Route path=":param" element={<Link to="./static">Click</Link>} />
</Route> When using a dynamic param that link will resolve to |
@@ -2895,7 +2973,7 @@ function testDomRouter( | |||
let { container } = render(<RouterProvider router={router} />); | |||
|
|||
expect(container.querySelector("form")?.getAttribute("action")).toBe( | |||
"/foo?a=1" | |||
"/foo/bar?a=1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This existing test was asserting the buggy behavior. When no action
is specified it should inherit the current path including the splat portion
@@ -2915,7 +2993,7 @@ function testDomRouter( | |||
let { container } = render(<RouterProvider router={router} />); | |||
|
|||
expect(container.querySelector("form")?.getAttribute("action")).toBe( | |||
"/foo" | |||
"/foo/bar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This existing test was asserting the buggy behavior. When action="."
is specified it should inherit the current path including the splat portion
@@ -530,7 +530,7 @@ describe("<Link> href", () => { | |||
}); | |||
|
|||
expect(renderer.root.findByType("a").props.href).toEqual( | |||
"/inbox/messages" | |||
"/inbox/messages/abc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above - this asserted the buggy behavior
expect(container.querySelector("form")?.getAttribute("action")).toBe( | ||
"/foo" | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New tests we didn't have before to ensure that the useResolvedPath
changes don't make us accidentally pick up child route portions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
This reverts commit f320378.
* Revert "Fix other code paths for resolveTo from a splat route (#11045)" This reverts commit 58d421f. * Revert "Add additional test case for #10983" This reverts commit f320378. * Revert "Fix issues with useFormAction/useResolvedPath for dot paths in param/splat routes (#10983)" This reverts commit fe066bd. * Fix test * Add changeset
Second shot at a fix for #10922
Originally fixed in #10933 and reverted in #10965 due to issues.
The main issue seems to boil down to
useResolvedPath
's longstanding behavior of usingpathnameBase
to construct the current route hierarchy.pathnameBase
never contains the splat - butpathname
does.This breaks a few existing uni tests that rely on the existing behavior - need to review with @mjackson.