material-web icon indicating copy to clipboard operation
material-web copied to clipboard

Button type submit

Open toastal opened this issue 6 years ago • 4 comments

I'm suprised this hasn't seemed to have come up, but you should be able to pass down button types like submit and reset. <mdc-button type="submit" ... />

toastal avatar Jan 28 '19 10:01 toastal

Related #205

dfreedm avatar Feb 06 '20 00:02 dfreedm

Ugly workaround: <mwc-button onclick="event.target.closest('form').submit()">.

salomvary avatar Jul 01 '20 09:07 salomvary

I just found out that this workaround is bad if you have submit event listeners. You would need to use https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/requestSubmit which is not supported in enough browsers. So I think this should be prioritized because implementation doesn't seem that hard and it's really annoying. The only workaround is probably to use the onclick for submitting which probably doesn't work when pressing enter or so. This also doesn't do form validation.

mohe2015 avatar Oct 11 '20 16:10 mohe2015

Any news on this?

maicol07 avatar Sep 22 '21 08:09 maicol07

Looking at the new implementation of the button component in https://github.com/material-components/material-web/blob/master/button/lib/button.ts

I noticed that type prop was missing again, is there a particular reason?

fernandopasik avatar Apr 08 '23 20:04 fernandopasik

I think it makes sense to add type when we update components to be Form Associated Custom Elements (FACE)

asyncliz avatar Apr 13 '23 16:04 asyncliz

Brilliant thank you! I noticed it's resolved https://github.com/material-components/material-web/blob/main/button/lib/button.ts#L76

fernandopasik avatar May 31 '23 19:05 fernandopasik