You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HTML spec says that a <button> element without an explicitly specified type attribute should be interpreted to have type=submit.
This makes some amount of sense for applications that consist of HTML forms that are submitted with such buttons, but Laminar is primarily designed for SPA applications, where most buttons do not submit any html forms.
Forgetting to specify type=button leads to buttons that do the wrong thing – submit the html form they're in – instead of performing the onClick or other action that we expect of them. And the way we're building our apps, the helper function in which the button is defined may not know whether it will be rendered in a form or not, so if type=button is not specified, it may work initially if rendered outside of the form, but fail when the button is moved to inside a form.
Correctly specifying type=button results in a bit of extra boilerplate for the majority use case.
High-level web component libraries such as Shoelace generally default to type=button in their button components. Lower level libraries like React.js generally stick to the native HTML behaviour, i.e. have type=submit as a default.
I'm wondering if Laminar should also default to type=button, even if it's decidedly a low level library. The type=submit default just seems to be so counter-productive. I'm well aware of this default, and yet I still often forget to specify type=button.
For me personally, building SPAs, type=submit is a rare use case, so I always specify it explicitly. I don't make use of the default in the spec, and personally would be happy to not need to type out type=button on 90% of the buttons I create.
Yet at the same time, adding a special type=button default to Laminar could confuse people. While the various HTML docs and tutorials including MDN generally specify type=submit attribute explicitly when it's intended to submit a form, if you do follow some tutorial that omits type=submit and relies on it being the default, you would need to look at Laminar docs to find why your form is not submitting, which goes against Laminar's general advice that you should look at html docs because Laminar behaves the way html behaves.
Normally we could hope for the standard / spec to improve eventually, but this is HTML – it will never change such a fundamental default, no matter how broken it is.
I haven't yet decided one way or another, except that whatever we choose, will be the only default available in Laminar, with no conditions and no configuration.
I would like to hear your opinion – regardless of whether you're experienced in Laminar / frontend / DOM / HTML or not.
Would having type=button as default improve Laminar ergonomics for you?
Do you often use button without specifying its type, relying on the default?
How surprised and frustrated would you be to encounter this non-standard default in Laminar, if you didn't know it was there?
The text was updated successfully, but these errors were encountered:
Personally, I've only used buttons with the type set to button; I'm in favour of this proposal.
Perhaps this could be mitigated with a separate button method, something like formButton or submit or formSubmit for instance to serve as a button with the "classic" HTML default?
HTML spec says that a
<button>
element without an explicitly specifiedtype
attribute should be interpreted to have type=submit.This makes some amount of sense for applications that consist of HTML forms that are submitted with such buttons, but Laminar is primarily designed for SPA applications, where most buttons do not submit any html forms.
Forgetting to specify type=button leads to buttons that do the wrong thing – submit the html form they're in – instead of performing the
onClick
or other action that we expect of them. And the way we're building our apps, the helper function in which the button is defined may not know whether it will be rendered in a form or not, so if type=button is not specified, it may work initially if rendered outside of the form, but fail when the button is moved to inside a form.Correctly specifying type=button results in a bit of extra boilerplate for the majority use case.
High-level web component libraries such as Shoelace generally default to type=button in their button components. Lower level libraries like React.js generally stick to the native HTML behaviour, i.e. have type=submit as a default.
I'm wondering if Laminar should also default to type=button, even if it's decidedly a low level library. The type=submit default just seems to be so counter-productive. I'm well aware of this default, and yet I still often forget to specify type=button.
For me personally, building SPAs, type=submit is a rare use case, so I always specify it explicitly. I don't make use of the default in the spec, and personally would be happy to not need to type out type=button on 90% of the buttons I create.
Yet at the same time, adding a special type=button default to Laminar could confuse people. While the various HTML docs and tutorials including MDN generally specify type=submit attribute explicitly when it's intended to submit a form, if you do follow some tutorial that omits type=submit and relies on it being the default, you would need to look at Laminar docs to find why your form is not submitting, which goes against Laminar's general advice that you should look at html docs because Laminar behaves the way html behaves.
Normally we could hope for the standard / spec to improve eventually, but this is HTML – it will never change such a fundamental default, no matter how broken it is.
I haven't yet decided one way or another, except that whatever we choose, will be the only default available in Laminar, with no conditions and no configuration.
I would like to hear your opinion – regardless of whether you're experienced in Laminar / frontend / DOM / HTML or not.
type=button
as default improve Laminar ergonomics for you?button
without specifying itstype
, relying on the default?The text was updated successfully, but these errors were encountered: