Skip to content

Commit

Permalink
feat: pass event to handler callback in useOutsideClick (#1998)
Browse files Browse the repository at this point in the history
  • Loading branch information
lolmaus authored Dec 24, 2024
1 parent 13ab300 commit 3097c80
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useOutsideClick/useOutsideClick.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

export interface UseOutsideClickProps<T> {
ref: React.RefObject<T>;
handler?: () => void;
handler?: (e: MouseEvent | TouchEvent) => void;
}

type UseOutsideClickType = <K extends HTMLElement>(props: UseOutsideClickProps<K>) => void;
Expand All @@ -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);
}
};

Expand Down

0 comments on commit 3097c80

Please sign in to comment.