S
SolidJS2mo ago
rendom

Solid.js onClick event is not firing when app is in ShadowRoot.

Solid.js onClick event is not firing when app is in ShadowRoot. Registered clicks only to component root, but not the elements inside the app.
6 Replies
rendom
rendom2mo ago
This known issue?
bigmistqke 🌈
bigmistqke 🌈2mo ago
It's probably the event delegation. Try on:click instead.
rendom
rendom2mo ago
@bigmistqke Thank you, its working now.
bigmistqke 🌈
bigmistqke 🌈2mo ago
Ur welcome 😁 Just fyi: event delegation is a lil trick solidjs uses for performance reasons. I don't know how it exactly works, but the main idea is that the handler is not attached to the element itself, but to the html-body instead. Since ur element is in the shadow dom that trick doesn't work. on:event is an escape hatch out of event delegation.
rendom
rendom2mo ago
Thank you for the clarification I was struggling with this issue for 2 days trying to figure out why my clicks not working.
mdynnl
mdynnl2mo ago
event delegation should still work if ShadowRoot is open
Want results from more Discord servers?
Add your server
More Posts