We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9e49e86 commit 7835ec8Copy full SHA for 7835ec8
1 file changed
src/hooks/useDetectMouseDownOutside.ts
@@ -24,6 +24,11 @@ function useDetectMouseDownOutside<Element extends HTMLElement>({
24
}: UseDetectMouseDownOutsideProps<Element>) {
25
useEffect(() => {
26
function handler(e: MouseEvent) {
27
+ // TODO: Fix this - doesnt work for fixed/absolute positioned items.
28
+ // Instead of checking if it's inside/outside the rect,
29
+ // we'll probs have to recursively check all children to see
30
+ // if the child element is equal to the event target. If so,
31
+ // the click is within, otherwise it's outside.
32
const bounds = elementRef.current?.getBoundingClientRect();
33
if (e.clientX < (bounds?.left ?? 0)) {
34
return onMouseDown();
0 commit comments