Fix outside click detection when component is mounted in the Shadow DOM in Vue

This commit is contained in:
Jordan Pittman
2023-12-05 11:22:33 -05:00
parent 7b30e06088
commit 684623131b
@@ -43,6 +43,7 @@ export function useRootContainers({
if (!(container instanceof HTMLElement)) continue // Skip non-HTMLElements
if (container.id === 'headlessui-portal-root') continue // Skip the Headless UI portal root
if (container.contains(dom(mainTreeNodeRef))) continue // Skip if it is the main app
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)
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)
containers.push(container)