Remix Form method GET not working as native browser Form #4044
wahyubucil
started this conversation in
Proposals
Replies: 2 comments 8 replies
-
Also, if we decided to not behave like a browser form and still provide the search params in the action, I had several solutions for handling the search params. But honestly, I still prefer to make Remix Form works as Native Browser Form just like the earlier version of Remix. |
Beta Was this translation helpful? Give feedback.
5 replies
-
Yeah this is buggy, I have a |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all, I'm a little bit confused about where to put this issue. At first, I thought it was an issue. But turnout I looked at the test it seems like it was built-in. I hope we can discuss it directly here.
So my problem is, that I create a simple form to search with a GET method, in the older version (1.5.1) it works as expected but not in the latest version.
Here's the demo: https://stackblitz.com/edit/node-sxbjyb
Suppose you're trying to submit. It will append every submitted value on search params instead of setting an existing one. Like this:
/?index=&q=test&q=test+again&q=test+third+time
I use the nightly build. If I use the latest one which is
1.6.8
. I will get:/?index=&index=&index=&q=test&q=test+again&q=test+third+time
. But I'm glad that the?index
issue is already resolved even tho it's not been released yet.I am looking at the remix source code. I think it's all because of this line. But I think it's not as simple as changing
append
toset
because we also need to support this use case.Something interesting happen when I decide to use the native browser Form. Native browser Form always replace all of the search params, instead of appending them. And I think that is supposed to be the expected behavior.
IMO, we need to change the
useFormAction
, if it's a GET and no action, then we just return the URL without any search params. If it's on the index route, we just return?index
without any other search params.It's not the framework's duty to provide the search params to the action. In my experience, it's always the framework user that defines search params. Whether we put it directly on the form action,
<input type="hidden" />
, or even sync it with the input value. It's all on us, not the framework. Even if we're using SPA, we need to make it sync with our state right?At first, I want to create a PR for this. But after seeing this test. I decide not to do it and prefer to discuss it first.
To conclude, we had 2 problems:
I think it's a major issue, so hopefully, we can clear it ASAP. Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions