From 2e8e554243580cf8977a334d4213164969f44f39 Mon Sep 17 00:00:00 2001 From: ngorin Date: Mon, 18 Sep 2023 15:49:17 +0300 Subject: [PATCH] feat: reafctor mouse event for web --- src/components/utils/useOutsideClick/useOutsideClick.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/utils/useOutsideClick/useOutsideClick.tsx b/src/components/utils/useOutsideClick/useOutsideClick.tsx index 68a8351758..29fcc95763 100644 --- a/src/components/utils/useOutsideClick/useOutsideClick.tsx +++ b/src/components/utils/useOutsideClick/useOutsideClick.tsx @@ -25,11 +25,11 @@ export const useOutsideClick: UseOutsideClickType = ({ref, handler}) => { } }; - window.addEventListener('click', callback, {capture: true}); + window.addEventListener('mousedown', callback, {capture: true}); window.addEventListener('touchend', callback, {capture: true}); return () => { - window.removeEventListener('click', callback, {capture: true}); + window.removeEventListener('mousedown', callback, {capture: true}); window.removeEventListener('touchend', callback, {capture: true}); }; }, [handler, ref]);