Skip to content
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

formAction successPath not respecting browser history #26

Closed
brunocrosier opened this issue Jun 3, 2022 · 7 comments
Closed

formAction successPath not respecting browser history #26

brunocrosier opened this issue Jun 3, 2022 · 7 comments

Comments

@brunocrosier
Copy link

If you visit the Custom Response example, then click on the Redirect example, and submit the form, you will be redirected to the /success page

However, if you then click the "Back" button in your browser, you are taken to the Custom Response example (instead of the Redirect example)

@NhielSalvana
Copy link

NhielSalvana commented Jun 14, 2022

@brunocrosier I'm sure this is not best practice but in my case, I patched this using patch-package.

npm install -D patch-package postinstall-postinstall

go to root directory
make a folder named patch inside it have a file named remix-forms+0.16.1.patch

inside /patch/remix-forms+0.16.1.patch

is

diff --git a/node_modules/remix-forms/lib/Form.js b/node_modules/remix-forms/lib/Form.js
index 616a327..4a4f3ea 100644
--- a/node_modules/remix-forms/lib/Form.js
+++ b/node_modules/remix-forms/lib/Form.js
@@ -69,7 +69,7 @@ function Form({ component = react_2.Form, fetcher, mode = 'onSubmit', renderFiel
         onTransition && onTransition({ transition, ...form });
     }, [transition.state]);
     const onSubmit = (event) => {
-        form.handleSubmit(() => submit(event.target, { replace: true }))(event);
+        form.handleSubmit(() => submit(event.target, { replace: false }))(event);
     };
     const Field = (0, react_1.useMemo)(() => (0, createField_1.default)({
         register: form.register,

add this to scripts in package.json

"scripts":{
   ....
  "postinstall": "patch-package"
  ....
  }

rm -rf node_modules

then lastly npm install

this patch wont work when remix-forms updates, which is okay, since higher versions might address this

@sobrinho
Copy link

Would you mind opening a PR fixing this?

@brunocrosier
Copy link
Author

is the code for the docs website (https://remix-forms.seasoned.cc) open source? if so, can you send a link to the repo?

@NhielSalvana
Copy link

NhielSalvana commented Jun 14, 2022

@brunocrosier here https://github.com/SeasonedSoftware/remix-forms-site

@sobrinho If you're referring to me. I still don't know why they opted for the default behavior of having onSubmit replace the browser stack, they might have future plans and designed it that way to pave way for that. So I'll wait for the author to be back before opening a PR :)

@sobrinho
Copy link

sobrinho commented Jun 15, 2022

@NhielSalvana I'm here in behalf of Seasoned, open the PR and I will open an internal discussion to define if we should merge it! ;)

@danielweinmann
Copy link
Contributor

Hey, guys! Sorry for the silence: I had to focus on other things for a few days.

@brunocrosier, here goes the code for the site. We plan to move it to this repo soon, so we can have a monorepo with the package + the site. We've been using the site as our dev environment to add E2E tests. In the meantime, feel free to use it on the other repo.

@NhielSalvana, the { replace: true } on the submit was there for the first use-case I had for Remix Forms but it doesn't make any sense anymore. I fixed it and published it on 0.16.2.

@danielweinmann
Copy link
Contributor

Thank you guys for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants