question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Form` post submission does not retain search parameters

See original GitHub issue

What version of Remix are you using?

1.4.3

Steps to Reproduce

Impement a route that includes search params in the url.

/my-route?param=1234

On the page include a post form

<Form method="post">
        <button type="submit>Submit</button>
</Form>

Native browser behaviour can be seen here thanks to @kiliman

https://codesandbox.io/s/form-action-params-8r86qw?file=/app/routes/test.tsx:732-987

Expected Behavior

Following the native browser behaviour, this should post back to /my-route?param=1234

Note that a method="get" post would natively replace the search params by the nature of the submission method

Actual Behavior

The form will post to the base path /my-route and trim off the search params

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:16
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
kilimancommented, May 10, 2022

@manV Yes, fixing this issue will solve your scenario.

You can “fix” it now, by manually specifying your action.

const location = useLocation()
return <Form action={`${location.pathname}${location.search}`}/>

The actual fix is to essentially do this automatically if action is not specified, as that is standard browser behavior.

0reactions
lili21commented, Aug 26, 2022

the latest version(1.6.8) already fixed the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When submitting a GET form, the query string is removed from ...
When method is POST, and form is submitted, Query parameters in action url were intact (req.query) and input element data was sent as...
Read more >
Solved: Retain specific form data when submitting
The form is in Formmode.new. When I press the "copy order + submit", I want to submit the entered data but copy some...
Read more >
Sending form data - Learn web development | MDN
Once the form data has been validated on the client-side, it is okay to submit the form. And, since we covered validation in...
Read more >
How can i submit form keeping existing query string intact in ...
Do you really need to submit your form with the use of 'GET' can't you use 'POST' instead? That could solve your problem...
Read more >
Pardot Form Handlers Troubleshooting - Salesforce Help
Pardot doesn't support submitting data to form handlers via Ajax requests. When attempting to submit data to a form handler using Ajax, you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found