modular-forms: [bug] formAction$ behaves differently on redirect than globalAction$

When you submit with a formAction$, the routeLoader$ fires and then fires again after the redirect. But, if you redirect from within qwik’s globalAction$ instead, routeLoader correctly only fires once (after the redirect).

I think the problem is formAction$ shouldn’t fire all loaders again before the redirect.

steps to reproduce: https://github.com/tuurbo/qwik-form-actions

qwik form (correct behavior)

  • click login link
  • click “login (qwik)” button
  • should see below in server console
loader /
loader /login/
formLoader
action (qwik)
loader /q-data.json

modular form (bad behavior)

  • clear server console
  • click login link
  • click “login (modular)” button
  • should see below in server console
loader /
loader /login/
formLoader
action (modular)
RedirectMessage {}             <----- not sure why this is logged
loader /login/q-data.json      <----- this should not be called
formLoader                     <----- this should not be called
loader /q-data.json

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 31 (19 by maintainers)

Commits related to this issue

Most upvoted comments

I understand. As long as the problem can be solved by changes to Modular Forms, I am very interested in implementing those changes directly. Since formAction$ is not extremely complicated and basically just builds on globalAction$, it should be quick once I know what to do.

@juanpmarin my comment was related to the previous comments on the Qwik 1.2.6 problem. I will fix the problem you describe soon. In production it should work normally.

Problem with Qwik 1.2.X should be fixed in v0.20.0 of Modular Forms. Make sure, this two imports are imported in the following order in entry.preview.tsx:

import qwikCityPlan from "@qwik-city-plan"; 
import render from "./entry.ssr";

Thank you for the hint. I will investigate this.

Thanks!

Note: It doesn’t work in dev but does work in prod. If I manually edit the modular form code in node_modules and insert console.log(error instanceof AbortMessage); it returns false in dev but in prod it returns true. Not sure anything can be done about that but I wanted to note it in case someone else runs into this issue.

I created a PR to speed up the process: https://github.com/BuilderIO/qwik/pull/4077