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

VSCodeButton triggers the form it belongs to onSubmit handler twice when triggered using the "Enter" key #394

Open
MichaelHindley opened this issue Aug 21, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@MichaelHindley
Copy link

Describe the bug

VSCodeButton triggers the form it belongs to onSubmit handler twice when triggered using the "Enter" key, firing two unique events to the onSubmit handler function.
If clicked with mouse, the onSubmit handler is called once, as expected.

Working workaround is to use any other button component.

Actual behavior:
Using the VSCodeButton react component to submit a form,
and the form submit is through pressing "enter",
the forms onSubmit handler triggers twice.

Compared to standard element:
Using a standard button element to submit a form,
and the form submit is through pressing "enter",
the forms onSubmit handler triggers one time.

Desired behavior
Using the VSCodeButton react component to submit a form,
and the form submit is through pressing "enter",
the forms onSubmit handler triggers one time.

To reproduce

Inside a webview panel:

        <form onSubmit={(e) => {
          e.preventDefault()
          console.log(e) // logs once
        }}>
          <button>Button</button>
        </form>

        <form onSubmit={(e) => {
          e.preventDefault()
          console.log(e) // logs twice
        }}>
          // note that "type='submit'" is required here due to a different bug
          <VSCodeButton type="submit">Button</VSCodeButton>
        </form>

Desktop (please complete the following information):

  • OS Version: [e.g. macOS 12.4]
  • Toolkit Version: [e.g. v1.0.0]
@MichaelHindley MichaelHindley added the bug Something isn't working label Aug 21, 2022
@hawkticehurst
Copy link
Member

Like I said, in your other issue thanks for reporting this! I'll add it to my list of things to look into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants