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

<Form/> cannot submitted via ‘action’ property #596

Open
ngrewe opened this issue Jun 25, 2023 · 0 comments
Open

<Form/> cannot submitted via ‘action’ property #596

ngrewe opened this issue Jun 25, 2023 · 0 comments

Comments

@ngrewe
Copy link

ngrewe commented Jun 25, 2023

I'm currently experimenting with a login form implemented using rc-field-form at its core that interacts with an OAuth2/OIDC implementation that expects a traditional server side rendered app for the login form. For this reason, I want to not attach an onFinish() callback to the form, but instead submit it via the native <form> submit mechanism, by setting the action property on the form, like so:

<Form name="test-form" action="https://httpstat.us/200" method="post">
  <Field name="test-field">
    <input placeholder="test field" value={""}/>
  </Field>
  <button type="submit" value={"submit"}>
    Submit
  </button>
</Form>

Since FormProps transitively extends React.FormHTMLAttributes I was expecting this to work, but of course it doesn't because here the event propagation of the submit click is stopped in favour of delegating processing to the form instance. I think rc-field-form's behaviour would be less surprising if event propagation were only stopped if:

  • Form validation fails
  • An on finish callback is actually attached to the form.

Of course, the alternative would be to omit action (and probably method) from FormProps, though that hardly seems satisfactory to me.

A demonstrator reproducing the bug can be found here: https://github.com/ngrewe/rc-field-form-bug

Thanks,

Niels

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

1 participant