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

fix(remix-react): Form's method shouldn't be ignored #4413

Merged
merged 3 commits into from
Oct 26, 2022

Conversation

maxschwarzmueller
Copy link
Contributor

Fixes #4412

@changeset-bot
Copy link

changeset-bot bot commented Oct 25, 2022

⚠️ No Changeset found

Latest commit: d9762d6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Oct 25, 2022

Hi @maxschwarzmueller,

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 CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Oct 25, 2022

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

Copy link
Collaborator

@machour machour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for the reproduction and fix @maxschwarzmueller !
Could you remove the generated file?
I'll get eyes on this PR today hopefully

integration/playwright-report/index.html Outdated Show resolved Hide resolved
@jenseng
Copy link
Contributor

jenseng commented Oct 25, 2022

The spec only supports POST and GET, so this change will make <Form> behave inconsistently with <form>. As a consequence, <Form> submissions may break if they happen before/without JavaScript.

@maxschwarzmueller
Copy link
Contributor Author

maxschwarzmueller commented Oct 25, 2022

The spec only supports POST and GET, so this change will make <Form> behave inconsistently with <form>. As a consequence, <Form> submissions may break if they happen before/without JavaScript.

I'm aware of the <form> default and spec. This is not a feature request but a bug fix as Remix documentation clearly states that Remix <Form> supports DELETE, PATCH etc. in addition to GET& POST: https://remix.run/docs/en/v1/api/remix#form-method

Or am I missing something here?

@machour
Copy link
Collaborator

machour commented Oct 25, 2022

@jenseng this is stressed out in the docs (https://remix.run/docs/en/v1/api/remix#form-method) but I'd love to see <Form> forbid anything that's not get or post, even when JS is running properly.

@maxschwarzmueller
Copy link
Contributor Author

I'll leave that up to you.
Personally, I see it as a huge plus that Remix supports DELETE etc. for <Form>. It's easy enough to stick to POST/GET and / or <form> if you want full spec-compliance + "no JS"-support.
This PR simply provides a fix to go back to the intended behavior. If it's not the wanted behavior, the docs should be updated.

@chaance
Copy link
Collaborator

chaance commented Oct 25, 2022

We definitely shouldn't break existing behavior, so limiting <Form> to GET and POST would need to be considered in a future major release. Probably worth opening a discussion for that if that's something you feel strongly about, as we have no plans for that at the moment. This is an intentional deviation from the basic <form> as noted in the docs. The no-JS tests should reflect those differences for now.

@jenseng
Copy link
Contributor

jenseng commented Oct 25, 2022

Sounds like there are two things going on here... if <Form method> or <button formMethod> are ignored, then that is buggy and should be fixed. Though I'm curious how it's broken without this change, as I think this logic looks correct, and the prior version of the uses the form method attribute test seems to be checking it, though I might be missing something here. EDIT: the logic I linked is wrong since it's looking at the form element's method, not the <Form>'s method prop.

As for other methods, those are great points on the docs and breaking changes. I wonder if we should more strongly discourage their usage (e.g. in dev mode do a console.warn)? One of Remix' big selling points is that it works before/without JavaScript, and this violates that.

@MichaelDeBoey MichaelDeBoey changed the title fix: Remix's <Form method> is ignored fix(remix-react): Form's method shouldn't be ignored Oct 25, 2022
@chaance
Copy link
Collaborator

chaance commented Oct 25, 2022

As for other methods, those are great points on the docs and breaking changes. I wonder if we should more strongly discourage their usage (e.g. in dev mode do a console.warn)? One of Remix' big selling points is that it works before/without JavaScript, and this violates that.

Would you like to start a new discussion on that? I think there's merit and I'd be happy to run it up the flag pole (aka get @ryanflorence to weigh in since his GH notifications are a tire fire 😂)

@jenseng
Copy link
Contributor

jenseng commented Oct 25, 2022 via email

@jenseng
Copy link
Contributor

jenseng commented Oct 25, 2022

Opened a discussion here

@chaance chaance merged commit 4e8cbd8 into remix-run:dev Oct 26, 2022
@chaance
Copy link
Collaborator

chaance commented Oct 26, 2022

Should be fixed in 1.7.4-pre.0. We'll get a stable release out tomorrow.

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v0.0.0-nightly-4e8cbd8-20221027 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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

Successfully merging this pull request may close these issues.

6 participants