S
SolidJS8mo 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
rendomOP8mo ago
This known issue?
bigmistqke
bigmistqke8mo ago
It's probably the event delegation. Try on:click instead.
rendom
rendomOP8mo ago
@bigmistqke Thank you, its working now.
bigmistqke
bigmistqke8mo 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
rendomOP8mo 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
mdynnl8mo ago
event delegation should still work if ShadowRoot is open
Want results from more Discord servers?
Add your server