-
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
[Bug]: useSubmitImpl() not respects incoming query search when using POST #931
Conversation
Hi @jacargentina, Welcome, and thank you for contributing to Remix! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
1 similar comment
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
Ah, the real problem here is that Your current solution is just always grabbing the current URL's search params, which is not what we want, it's the form that determines the action we're posting to, not the current page. The mixup is that If you do That logic is in |
Actually this seems to go deep. @chaance can you look into this? I think this is busted all the way back into React Router, |
The behavior in React Router is as intended. I'll take a look at this tomorrow morning and make sure we get it fixed. |
@ryanflorence Ok. |
@jacargentina That would actually be quite helpful, thanks! I'll be adding a few more tests as well. |
@chaance i want to migrate my NextJS site to Remix, please. I depend on this. |
I made this little contraption to work around that problem for the time being: import { useFormAction, useSearchParams } from '@remix-run/react'
/**
* Hook to work around https://github.com/remix-run/remix/pull/931
*/
export default function useFormActionWithSearchParams(to: string = '.') {
const actionUrl = new URL(useFormAction(to), 'http://localhost')
const [actionSearch] = useSearchParams()
const combinedSearch = new URLSearchParams({
...Object.fromEntries(actionUrl.searchParams),
...Object.fromEntries(actionSearch),
})
return actionUrl.pathname + '?' + combinedSearch.toString()
} <Form action={useFormActionWithSearchParams()} > |
🤖 Hello there, We just published version Thanks! |
My first contribution. This tests shows the bug explained on #927