react-easy-edit icon indicating copy to clipboard operation
react-easy-edit copied to clipboard

Attribute type is missing in button

Open spacecat opened this issue 1 year ago • 0 comments

The generated markup looks like this:

<button class="easy-edit-button" name="edit">Edit</button>

By default a button has type submit. Which is not what we're dealing with when clicking the Edit button. So it should have type="button" as the default.

From ChatGPT:

In HTML, the type attribute on a <button> element is not strictly required, but it is recommended to specify it for clarity and to avoid potential unintended behavior. The type attribute can have three possible values:

  • submit (default): Submits the form data.
  • button: Acts as a general-purpose button (does nothing by default).
  • reset: Resets the form data.

If you don't specify a type, the button will default to submit in a form context. This can be problematic if you intended it to be a general-purpose button, as it could accidentally submit a form when clicked. To avoid this, it's a good practice to explicitly set the type attribute.

For example:

<button type="button">Click me</button>

This ensures the button won't submit a form unless you want it to.

Edit: Same with Save and Cancel buttons. And probably all other buttons as well.

spacecat avatar Oct 16 '24 15:10 spacecat