-
Notifications
You must be signed in to change notification settings - Fork 115
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
Fetcher with {...getFormProps(form)}
causes a navigation to the action
#444
Comments
Conform is only calling
Keep in mind this is true only if you are running with JS. When you submit a form before JS loaded, it will still be a navigation due to how browser works with the form element. Also, if you redirect in the action, it will still cause a navigation. I will suggest you to remove the |
Got it, so is the solution to not add the |
No. I am just suggesting this is very likely a Remix behaviour and you will observe the same behaviour even without |
So just to clear things up and to just let you know what I am seeing (JS loaded in both examples)
So I think you are saying that I should add code to prevent a redirect even if remix handles it automatically with JS because if JS is not loaded it would redirect me? |
It will be great if you can create a repo with the issue you had. You can use the example here: https://stackblitz.com/github/edmundhung/conform/tree/main/examples/remix?file=app%2Froutes%2Flogin-fetcher.tsx Conform does nothing in addition to |
This is the best I was able to repro. In this repro case it only breaks when I do add the https://stackblitz.com/edit/github-kv6hgp?file=app%2Froutes%2Flogin-fetcher.tsx Click |
The issue your repo has is caused by missing form <fetcherWithAction.Form
method="POST"
action="/some-action"
id={formWithAction.id}
onSubmit={formWithAction.onSubmit}
/> This is probably not the exact issue you had as the <fetcherWithAction.Form
method="POST"
action="/some-action"
id={formWithAction.id}
onSubmit={event => {
try {
formWithAction.onSubmit(event);
} catch (exception) {
console.log(exception);
}
}}
/> You can also wrap the |
Oh interesting, my issue is caused by this: #375 This is the exception being thrown from the
I also see this error in my console when i reload the page:
The fixes in #375 haven't worked for me. I am on remix v2.6 and conform v1.0.1. But its interesting that the repro case isn't having this issue. Must be something wrong with my app, but I haven't been able to narrow down why its happening. |
Ok so I have an app that uses MUI and the set up is very similiar to this https://github.com/mui/material-ui/tree/master/examples/material-ui-remix-ts) in the Seems like this is a me issue that I'll need to figure out. Going to close. |
In case you have trouble fixing the mismatch in a short time, you can consider hard-coding the id of the form for now, e.g. const [form, fields] = useForm({
id: 'example',
}); Just be aware that the id has to be unique if you might render multiple forms at the same time. And the issue is likely happening on other non fetcher form but feels working due to how resilient Remix + Conform is 😅 |
Something interesting I found is that even with the fix I made, I will still get the error Which I guess makes sense since they'll have the same ID but just something I didn't know. |
Describe the bug and the expected behavior
When you submit a fetcher when using
{...getFormProps(form)}
it will navigate to theaction
route. Based on remix docs a Fetcher shouldn't cause a navigation https://remix.run/docs/en/main/hooks/use-fetcher#fetcherformConform version
v1.0.1
Steps to Reproduce the Bug or Issue
When submitting this fetcher, it causes the browser to navigate to
/some/route
What browsers are you seeing the problem on?
Chrome
Screenshots or Videos
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: