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

[BUG] Numeric input increase/decrease button causes form submit #1011

Closed
roffus opened this issue Feb 1, 2024 · 2 comments · Fixed by #1007
Closed

[BUG] Numeric input increase/decrease button causes form submit #1011

roffus opened this issue Feb 1, 2024 · 2 comments · Fixed by #1007
Assignees
Labels
Milestone

Comments

@roffus
Copy link

roffus commented Feb 1, 2024

Describe the bug
When you have a form with a numeric input, if you try to increase or decrease the value, the button triggers the submission of the form.

@roffus roffus added the bug label Feb 1, 2024
@Virtute90
Copy link
Collaborator

Describe the bug When you have a form with a numeric input, if you try to increase or decrease the value, the button triggers the submission of the form.

hi @roffus, can you write code that reproduces this error?

@roffus
Copy link
Author

roffus commented Feb 2, 2024

I'm using useForm hook, but I think it's not related to that library.
I see that the two buttons (.input-number-add and .input-number-sub) has not a type attribute and the default is submit.
So probably it's enough to add type:"button" to solve this issue

const App = () => {
  const { control, handleSubmit } = useForm<any>({ mode: 'onChange' });
  const onSubmit = () => {
    console.log('submit');
  };
  return (
    <form style={{ width: '100px' }} onSubmit={handleSubmit(onSubmit)}>
      <Input control={control} name="name" type="number" />
    </form>
  );
};

@astagi astagi self-assigned this Feb 5, 2024
@astagi astagi added this to the Version 5.0.0 milestone Feb 5, 2024
@astagi astagi linked a pull request Feb 6, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants