Skip to content

Commit

Permalink
Ignore disconnected elements for outside clicks (#2544)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Jun 19, 2023
1 parent 14b8c56 commit 0a9276d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/@headlessui-react/src/hooks/use-outside-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

2 comments on commit 0a9276d

@vercel
Copy link

@vercel vercel bot commented on 0a9276d Jun 19, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

headlessui-vue – ./packages/playground-vue

headlessui-vue.vercel.app
headlessui-vue-git-main-tailwindlabs.vercel.app
headlessui-vue-tailwindlabs.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 0a9276d Jun 19, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

headlessui-react – ./packages/playground-react

headlessui-react.vercel.app
headlessui-react-git-main-tailwindlabs.vercel.app
headlessui-react-tailwindlabs.vercel.app

Please sign in to comment.