Submitting forms in parent layout routes tries posting to wrong action.
MoSattler opened this issue · comments
Hey, I posted the same issue in the remix repo (remix-run/react-router#11024), but someone mentioned this could be an issue with the flat-route package as well. I am using "remix-flat-routes": "^0.6.2"
.
What version of Remix are you using?
2.2.0
Are all your remix dependencies & dev-dependencies using the same version?
- Yes
Steps to Reproduce
I have a layout route on
my-parent.$someParam.tsx
which adds a form and a action to handle the form.
inside that route there are three children:
my-parent._index.tsx
my-parent.$someParam.my-child.tsx
my-parent.$someParam.my-child._index.tsx
Now, when I am submitting the form on /my-parent/some-value/my-child
, everything works as expected.
But if I am on /my-parent/some-value/my-child?index
, and I try submit, I get the following error:
405 Error: Route "routes/my-parent._index.tsx" does not have an action, but you are trying to submit to it. To fix this, please add an action function to the route.
Expected Behavior
Forms should always submit to the action in their route, not some other route
Actual Behavior
For some reason, if i am on the ?index
path of some child route, actions of parent layout routes also try to post on their respective index routes
As a temporary fix I have done this in my-parent.$someParam.my-child._index.tsx
:
export { action } from "#my-parent.$someParam.my-child"
As I stated in remix-run/react-router#11024 this is how Remix works.
As I stated in remix-run/react-router#11024 this is how Remix works.
Not quite, it is a bug in remix.