Skip to content

Commit

Permalink
[@mantine/hooks] use-click-outside: Fix incorrect outside clicks dete…
Browse files Browse the repository at this point in the history
…ction when click target is html element (#3143)
  • Loading branch information
rtivital committed Dec 12, 2022
1 parent 262b380 commit 012c9b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mantine-hooks/src/use-click-outside/use-click-outside.ts
Expand Up @@ -14,7 +14,8 @@ export function useClickOutside<T extends HTMLElement = any>(
const { target } = event ?? {};
if (Array.isArray(nodes)) {
const shouldIgnore =
target?.hasAttribute('data-ignore-outside-clicks') || !document.body.contains(target);
target?.hasAttribute('data-ignore-outside-clicks') ||
(!document.body.contains(target) && target.tagName !== 'HTML');
const shouldTrigger = nodes.every((node) => !!node && !event.composedPath().includes(node));
shouldTrigger && !shouldIgnore && handler();
} else if (ref.current && !ref.current.contains(target)) {
Expand Down

0 comments on commit 012c9b9

Please sign in to comment.