S
SolidJS10mo 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
rendomOP10mo ago
This known issue?
bigmistqke
bigmistqke10mo ago
It's probably the event delegation. Try on:click instead.
rendom
rendomOP10mo ago
@bigmistqke Thank you, its working now.
bigmistqke
bigmistqke10mo 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
rendomOP10mo 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
mdynnl10mo ago
event delegation should still work if ShadowRoot is open

Did you find this page helpful?