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
This known issue?
It's probably the event delegation. Try
on:click
instead.@bigmistqke Thank you, its working now.
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.Thank you for the clarification I was struggling with this issue for 2 days trying to figure out why my clicks not working.
event delegation should still work if ShadowRoot is open