Skip to content

Commit 539bb11

Browse files
committed
fix: click on shadowDOM popup should not close it
1 parent c629b9c commit 539bb11

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/index.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,23 @@ export function generateTrigger(
272272
const originChildProps = child?.props || {};
273273
const cloneProps: typeof originChildProps = {};
274274

275+
const inContainer = (container: Element, target: Element) => {
276+
return (
277+
target === container ||
278+
container.contains(target) ||
279+
getShadowRoot(container)?.host === target ||
280+
container.contains(getShadowRoot(target)?.host)
281+
);
282+
};
283+
275284
const inPopupOrChild = useEvent((ele: EventTarget) => {
276285
const childDOM = targetEle;
277286

278287
return (
279-
childDOM?.contains(ele as HTMLElement) ||
280-
getShadowRoot(childDOM)?.host === ele ||
281-
ele === childDOM ||
282-
popupEle?.contains(ele as HTMLElement) ||
283-
getShadowRoot(popupEle)?.host === ele ||
284-
ele === popupEle ||
285-
Object.values(subPopupElements.current).some(
286-
(subPopupEle) =>
287-
subPopupEle?.contains(ele as HTMLElement) || ele === subPopupEle,
288+
inContainer(childDOM, ele as Element) ||
289+
inContainer(popupEle, ele as Element) ||
290+
Object.values(subPopupElements.current).some((subPopupEle) =>
291+
inContainer(subPopupEle, ele as Element),
288292
)
289293
);
290294
});

0 commit comments

Comments
 (0)