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

Attribute type is missing in button #206

Open
spacecat opened this issue Oct 16, 2024 · 0 comments
Open

Attribute type is missing in button #206

spacecat opened this issue Oct 16, 2024 · 0 comments

Comments

@spacecat
Copy link

spacecat commented Oct 16, 2024

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.

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