Ignore disconnected elements for outside clicks (#2544)

This commit is contained in:
Jordan Pittman
2023-06-19 16:02:38 -04:00
committed by GitHub
parent 14b8c56226
commit 0a9276d205
@@ -47,6 +47,9 @@ export function useOutsideClick(
// Ignore if the target doesn't exist in the DOM anymore
if (!target.getRootNode().contains(target)) return
// Ignore if the target was removed from the DOM by the time the handler was called
if (!target.isConnected) return
let _containers = (function resolve(containers): ContainerCollection {
if (typeof containers === 'function') {
return resolve(containers())