You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For instance, using the property onClick will register a delegated event handler, while the on:click property will register a native event listener.
ArkUI attaches its own event listeners using the delegated syntax, which in some cases, like in the Tooltip focus handlers, or in the Select outside click handler, breaks functionality when it's used inside a shadow root.
This can be somewhat mitigated by fixing the events on runtime if using asChild, using the following approach:
import{HTMLProps}from"@ark-ui/solid/factory";import{JSX}from"solid-js/jsx-runtime";typeElementType=keyofJSX.IntrinsicElements;/** * Converts SolidJS delegated events to native events * * https://github.com/chakra-ui/ark/issues/3146#issuecomment-2556518786 * * https://docs.solidjs.com/concepts/components/event-handlers#list-of-delegated-events */exportfunctioneventFixer<EextendsElementType>(props: HTMLProps<E>){constnewObj: Record<string,unknown>={};Object.entries(props).forEach(([key,value])=>{constlowerCaseKey=key.toLowerCase();lettrimmedKey=lowerCaseKey;// it's an event handlerif(lowerCaseKey.startsWith("on")){trimmedKey=lowerCaseKey.slice(2);constnewKey=`on:${trimmedKey}`;newObj[newKey]=value;}else{// if it's not an event handlernewObj[trimmedKey]=value;}});returnnewObj;}
This however does not work on custom events like Select's onInteractOutside.
Description
SolidJS uses event delegation for the following events:
https://docs.solidjs.com/concepts/components/event-handlers#list-of-delegated-events
For instance, using the property
onClick
will register a delegated event handler, while theon:click
property will register a native event listener.ArkUI attaches its own event listeners using the delegated syntax, which in some cases, like in the
Tooltip
focus handlers, or in theSelect
outside click handler, breaks functionality when it's used inside a shadow root.This can be somewhat mitigated by fixing the events on runtime if using
asChild
, using the following approach:This however does not work on custom events like
Select
'sonInteractOutside
.Link to Reproduction (or Detailed Explanation)
https://stackblitz.com/~/github.com/ivancuric/solidjs-templates-yge8guon?file=src/App.tsx
Steps to Reproduce
Ark UI Version
5.0.0
Framework
Browser
Chrome
Additional Information
related issue: #3146
The text was updated successfully, but these errors were encountered: