Skip to content

Commit 7f405f0

Browse files
committed
fix: can not open in web component
1 parent 7781194 commit 7f405f0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/hooks/useSelectTriggerControl.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ export default function useSelectTriggerControl(
1414

1515
React.useEffect(() => {
1616
function onGlobalMouseDown(event: MouseEvent) {
17-
const target = event.target as HTMLElement;
17+
let target = event.target as HTMLElement;
18+
19+
if (target.shadowRoot && event.composed) {
20+
target = (event.composedPath()[0] || target) as HTMLElement;
21+
}
22+
1823
if (
1924
propsRef.current.open &&
20-
propsRef.current.elements.every(
21-
element => !element.contains(target) && element !== target,
22-
)
25+
propsRef.current.elements.every(element => !element.contains(target) && element !== target)
2326
) {
2427
// Should trigger close
2528
propsRef.current.triggerOpen(false);

0 commit comments

Comments
 (0)