From 3097c80137b5531cd9d0e3afa9e414dfbca2d424 Mon Sep 17 00:00:00 2001 From: "Andrey Mikhaylov (lolmaus)" Date: Tue, 24 Dec 2024 16:43:59 +0300 Subject: [PATCH] feat: pass event to handler callback in useOutsideClick (#1998) --- src/hooks/useOutsideClick/useOutsideClick.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useOutsideClick/useOutsideClick.tsx b/src/hooks/useOutsideClick/useOutsideClick.tsx index 6f7b2c5b44..c8dfcde2df 100644 --- a/src/hooks/useOutsideClick/useOutsideClick.tsx +++ b/src/hooks/useOutsideClick/useOutsideClick.tsx @@ -2,7 +2,7 @@ import React from 'react'; export interface UseOutsideClickProps { ref: React.RefObject; - handler?: () => void; + handler?: (e: MouseEvent | TouchEvent) => void; } type UseOutsideClickType = (props: UseOutsideClickProps) => void; @@ -21,7 +21,7 @@ export const useOutsideClick: UseOutsideClickType = ({ref, handler}) => { const elem = ref?.current; if (elem && !elem.contains(e.target as Node) && handler) { - handler(); + handler(e); } };