Skip to content

Button component has no default type #2806

@pveierland

Description

@pveierland

Description

The Button component does not have a default type attribute. In e.g. react-bootstrap, the Button component by default has type set to button. Without such a default, the type will default to submit within forms, yielding the following warning when using e.g. Formik:

You submitted a Formik form using a button with an unspecified type attribute. Most browsers default button elements to type="submit". If this is not a submit button, please add type="button".

As it is normal to add multiple buttons within a form, it seems safer and more intuitive to have a default type set to button, and then explicitly specify which button to use for submission.

Steps to reproduce

  1. Create page with the following form:
<form>
<Button type="submit">Submit</Button>
<Button>Recalculate<Button>
</form>
  1. The second button will default to type=submit instead of type=button. Expected behavior would be that the second Button type would default to button.

Version

v35.2.0

Browser

Firefox

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomponent: ButtonIssues related to the Button componentreact

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions