Skip to content

Commit

Permalink
fix: can not open in web component (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tmk authored Feb 6, 2021
1 parent a15a8ad commit d93924e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/hooks/useSelectTriggerControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ export default function useSelectTriggerControl(

React.useEffect(() => {
function onGlobalMouseDown(event: MouseEvent) {
const target = event.target as HTMLElement;
let target = event.target as HTMLElement;

if (target.shadowRoot && event.composed) {
target = (event.composedPath()[0] || target) as HTMLElement;
}

if (
propsRef.current.open &&
propsRef.current.elements.every(
element => !element.contains(target) && element !== target,
)
propsRef.current.elements.every(element => !element.contains(target) && element !== target)
) {
// Should trigger close
propsRef.current.triggerOpen(false);
Expand Down

1 comment on commit d93924e

@vercel
Copy link

@vercel vercel bot commented on d93924e Feb 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.