File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -176,12 +176,11 @@ export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement))
176176 }
177177
178178 /**
179- * Prevent normal click and redispatch click on the native button unless already redispatched.
179+ * Prevent normal click and redispatch submit on the native button unless already redispatched.
180180 */
181- __clickDelegationHandler ( e ) {
182- if ( ! e . __isRedispatchedOnNativeButton ) {
183- e . stopImmediatePropagation ( ) ;
184- this . _redispatchClickEvent ( e ) ;
181+ __clickDelegationHandler ( ) {
182+ if ( this . type === 'submit' && this . _nativeButtonNode . form ) {
183+ this . _nativeButtonNode . form . submit ( ) ;
185184 }
186185 }
187186
Original file line number Diff line number Diff line change @@ -35,9 +35,10 @@ storiesOf('Buttons|Button', module)
3535 . add (
3636 'Within a form' ,
3737 ( ) => html `
38- < lion-form id ="form "
38+ < lion-form id ="form " @submit = ${ ( ) => console . log ( 'form submitted' ) }
3939 > < form >
4040 < lion-input name ="foo " label ="Foo " .modelValue =${ 'bar' } > </ lion-input >
41+ < lion-input name ="foo2 " label ="Foo2 " .modelValue =${ 'bar' } > </ lion-input >
4142 < lion-button
4243 type ="submit "
4344 @click =${ ( ) => console . log ( document . querySelector ( '#form' ) . serializeGroup ( ) ) }
@@ -46,4 +47,16 @@ storiesOf('Buttons|Button', module)
4647 </ form > </ lion-form
4748 >
4849 ` ,
49- ) ;
50+ )
51+ . add ( 'Within another form' , ( ) => {
52+ const submitForm = ( ) => console . log ( 'hey' ) ;
53+ return html `
54+ < form id ="form " @submit =${ submitForm } >
55+ < h3 > Details</ h3 >
56+ < input name ="input1 " />
57+ < input name ="input2 " />
58+ < input name ="input3 " />
59+ < lion-button > Submit</ lion-button >
60+ </ form >
61+ ` ;
62+ } ) ;
You can’t perform that action at this time.
0 commit comments