-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Bug]: useResolvedPath breaks <Form> when used in a splat route #10922
Comments
Thanks for the issue and thorough investigation! |
This is resolved by #10933 and will be available in the next release. |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
No no silly bot - this was fixed but reverted - this is still an issue in 6.18.0. |
ok, this is fixed again in #10983 - should be out in the next release |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
FYI - it turns out a large number of existing apps were relying on this buggy behavior so we decided to revert this and we will re-release the fix behind a future flag in the next minor release (see #11052 (comment)). |
What version of React Router are you using?
6.16.0
Steps to Reproduce
https://stackblitz.com/edit/github-btbhnm?file=src%2FApp.tsx
Create a simple splat route:
Inside your splat route, use a
<Form method="post">
without explicitaction
attribute:Navigate to, for example,
/admin/pages/hello/world
and submit your form to, for example, update your page in the database or whatever, using the following action:Expected Behavior
The form should submit to /admin/pages/hello/world (or whatever route it's currently on) when no action attribute has been specified.
Actual Behavior
Inspect the dom and you'll see the form generated form has
/admin/pages
for an action:This will break your action code that expects a value inside your
params["*"]
object.I deep a deep dive and found that internally, the Form will use
useResolvedPath(".")
when no action is specifed and that hook already seems to return the top of the path for splat routes, in this example always /admin/pages. However, callinguseResolvedPath(useLocation().pathname)
will find the splat route correctly.So it seems that the special case of resolving
"."
doesn't work as expected in splat routes.The text was updated successfully, but these errors were encountered: