remix icon indicating copy to clipboard operation
remix copied to clipboard

[Bug]: `reloadDocument` prop on `Form` does not mimic browser behavior

Open jensmeindertsma opened this issue 3 years ago • 3 comments

What version of Remix are you using?

1.0.6

What version of Node are you using? Minimum supported version is 14.

17.1.0

Steps to Reproduce

  1. Clone my reproduction repository
  2. npm install
  3. npm run dev
  4. Open the browser DevTools Network tab
  5. Submit the form ( request is a POST )
  6. See the error show up
  7. Refresh the page ( request is a POST )
  8. See the error be present still on the page ( as the POST was retried )
  9. Enable JS on the page by setting hydrate to true in app/routes/index.tsx
  10. Submit the form ( request is a POST )
  11. See the error show up
  12. Refresh the page ( request is a GET )
  13. See the error has disappeared ( as request was not a form submission )
  14. Set the reloadDocument prop on Form in routes/index.tsx to true
  15. Retry steps 5 - 13 and notice reloadDocument doesn't make a difference

Expected Behavior

I would expect the request in step 12 to be a POST, just like it was without JS. Perhaps this should be the default behavior, or otherwise it could be opt-in?

Actual Behavior

The request in step 12 is a GET, even when using reloadDocument

jensmeindertsma avatar Dec 05 '21 19:12 jensmeindertsma

As mentioned by @kentcdodds in Discord:

Originally Ryan had made it so a refresh would trigger the request again in a useEffect and I complained because it was unexpected. He told me that's what the browser does without JavaScript and I said I didn't care and that this is unexpected for users of modern apps. He agreed.

jensmeindertsma avatar Dec 05 '21 19:12 jensmeindertsma

Really the crux of my question is: -> When JS is enabled, the form error disappears after a refresh. A refresh does not reattempt the submit using the old data. -> When JS is disabled, the form error stays after a refresh. A refresh reattempts the old request Where does the difference between these two come from and is there any chance they will be aligned in the future? Or is this a bad idea?

jensmeindertsma avatar Dec 05 '21 19:12 jensmeindertsma

@jensmeindertsma I'm going through old issues to see what's fixed, and I see your reproduction repository doesn't exist anymore.

Is this still an issue for you?

machour avatar Jan 22 '23 10:01 machour

This issue has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from issues that are unactionable. Please reach out if you have more information for us! 🙂

github-actions[bot] avatar Feb 01 '23 10:02 github-actions[bot]