Skip to content

Commit 7835ec8

Browse files
committed
Add todo
1 parent 9e49e86 commit 7835ec8

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/hooks/useDetectMouseDownOutside.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ function useDetectMouseDownOutside<Element extends HTMLElement>({
2424
}: UseDetectMouseDownOutsideProps<Element>) {
2525
useEffect(() => {
2626
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.
2732
const bounds = elementRef.current?.getBoundingClientRect();
2833
if (e.clientX < (bounds?.left ?? 0)) {
2934
return onMouseDown();

0 commit comments

Comments
 (0)