Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,23 @@ export function generateTrigger(
const originChildProps = child?.props || {};
const cloneProps: typeof originChildProps = {};

const inContainer = (container: Element, target: Element) => {
return (
target === container ||
container.contains(target) ||
getShadowRoot(container)?.host === target ||
container.contains(getShadowRoot(target)?.host)
);
};

const inPopupOrChild = useEvent((ele: EventTarget) => {
const childDOM = targetEle;

return (
childDOM?.contains(ele as HTMLElement) ||
getShadowRoot(childDOM)?.host === ele ||
ele === childDOM ||
popupEle?.contains(ele as HTMLElement) ||
getShadowRoot(popupEle)?.host === ele ||
ele === popupEle ||
Object.values(subPopupElements.current).some(
(subPopupEle) =>
subPopupEle?.contains(ele as HTMLElement) || ele === subPopupEle,
inContainer(childDOM, ele as Element) ||
inContainer(popupEle, ele as Element) ||
Object.values(subPopupElements.current).some((subPopupEle) =>
inContainer(subPopupEle, ele as Element),
)
);
});
Expand Down