Skip to content

Commit cad806b

Browse files
authored
fix: Mouse panning when used in shadow DOM (#448)
1 parent 6167676 commit cad806b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/core/pan/panning.utils.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ export const isPanningStartAllowed = (
1616
const { isInitialized, wrapperComponent } = contextInstance;
1717

1818
const target = event.target as HTMLElement;
19-
const isWrapperChild = wrapperComponent?.contains(target);
19+
const targetIsShadowDom = "shadowRoot" in target && "composedPath" in event;
20+
const isWrapperChild = targetIsShadowDom
21+
? event.composedPath().some((el) => {
22+
if (!(el instanceof Element)) {
23+
return false;
24+
}
25+
26+
return wrapperComponent?.contains(el);
27+
})
28+
: wrapperComponent?.contains(target);
29+
2030
const isAllowed = isInitialized && target && isWrapperChild;
2131

2232
if (!isAllowed) return false;

0 commit comments

Comments
 (0)