-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Children Outlet route intercepts Layout action #8923
Comments
It's not a bug. When you submit, by default it will POST to the the URL the user is currently on. Once you submitted from This meant when you submitted from your parent layout, it will POST to the NOTE: https://remix.run/docs/en/main/hooks/use-submit#options <button
onClick={() => {
submit(
{ _action: 'app.tsx' },
{
action: '.',
method: 'POST',
replace: true,
encType: 'multipart/form-data',
navigate: false,
}
);
}}
> |
I see, setting |
Remix is trying to emulate the default browser behavior. For forms, a missing or empty Also, the browser will not submit to a partial URL without a specific action specified. When specifying paths in Remix (React-Router) in |
I think this is actually a bug in the Remix should by default post to the contextual export function action () {}
export default function Component() {
// When no action is specified - this should default to the action for this route
return <Form method="post">...</Form>
} This is currently working correctly for That doesn't happen for export function action () {}
export default function Component() {
let submit = useSubmit()
// When no action is specified - this should *also* default to the action for this route
return <button onClick={() => submit({}, { method: 'post' })}>...</button>
} |
This is fixed by remix-run/react-router#12003 and will be available in the next release 👍 |
Reproduction
https://stackblitz.com/edit/remix-run-remix-2up1w8
System Info
Used Package Manager
npm
Expected Behavior
Button with
submit()
placed in the Layout route should trigger the action of its corresponding action, independently if the current route is nested or has query params.Actual Behavior
Once you have submitted an action from an Outlet route and that action appends the search param
?index
, when the button in the parent Layout route submits an action, that action will be intercepted by the Outlet route action (app._index.tsx
) instead of it being read by the Layout route (app.tsx
)The text was updated successfully, but these errors were encountered: