Skip to content

Commit 6846231

Browse files
committed
Fix outside click detection when component is mounted in the Shadow DOM in Vue
1 parent 7b30e06 commit 6846231

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/@headlessui-vue/src/hooks/use-root-containers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function useRootContainers({
4343
if (!(container instanceof HTMLElement)) continue // Skip non-HTMLElements
4444
if (container.id === 'headlessui-portal-root') continue // Skip the Headless UI portal root
4545
if (container.contains(dom(mainTreeNodeRef))) continue // Skip if it is the main app
46+
if (container.contains((dom(mainTreeNodeRef)?.getRootNode() as ShadowRoot)?.host)) continue // Skip if it is the main app (and the component is inside a shadow root)
4647
if (containers.some((defaultContainer) => container.contains(defaultContainer))) continue // Skip if the current container is part of a container we've already seen (e.g.: default container / portal)
4748

4849
containers.push(container)

0 commit comments

Comments
 (0)