-
Notifications
You must be signed in to change notification settings - Fork 319
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
LitElement prevents form submit event from bubbling #832
Comments
This isn't a LitElement issue. The problem is that the input and the event listener are in different shadow roots, but You'll need to re-fire the event from the child component, use the form participation API, or take the input and submit button as slotted children. |
Excuse me, can you elaborate this with a concrete example? Because even then it didn't work for me. I actually have this exact use case from the beginning on, using slotted children, but I'm still facing the issue of the submit event apparently not hitting the form element itself when triggered by a slotted input or button. Here's the reproducer: https://jsfiddle.net/nhxuLpc6/ |
@BalusC in that example your form and input are in different shadow roots. Form associated custom elements may help you here |
Potentially related: WICG/webcomponents#1075 |
What exactly did you mean then when you said "take the input and submit button as slotted children"? Because I understood that my exact example already represents that. |
I mean slotting the input and button into the custom element, from where the form is: <form>
<my-element>
<input slot="input" type="text">
<button slot="button" type="submit">Submit</button>
</my-element>
</form> |
Right. Thanks. |
Description
On the parent element, it is not possible to listen for the 'submit' event fired by the child element.
Live Demo
lit-element example: https://jsfiddle.net/ao9u3tsw/2/
Pure js example: https://jsfiddle.net/arjv9kt1/
Steps to Reproduce
Expected Results
The event listener function to be called.
Actual Results
The event listener function is not called.
Browsers Affected
Did not check for the rest.
Versions
The text was updated successfully, but these errors were encountered: