diff --git a/frontend/src/components/Modal.tsx b/frontend/src/components/Modal.tsx index 16699ba..f07d22f 100644 --- a/frontend/src/components/Modal.tsx +++ b/frontend/src/components/Modal.tsx @@ -23,6 +23,11 @@ export default function Modal({ // Browser/mouse Back closes the topmost modal instead of navigating away. useBackToClose(onClose); + // Backdrop-click close must only fire when the press STARTED on the backdrop too. Otherwise a + // drag that begins inside the dialog (e.g. selecting text in an input) and is released out on + // the backdrop wrongly dismisses — the click event bubbles to the common ancestor (the backdrop). + const pressedOnBackdrop = useRef(false); + // Keep a stable handler across renders so the stack id is assigned once per mount. const onCloseRef = useRef(onClose); onCloseRef.current = onClose; @@ -48,13 +53,17 @@ export default function Modal({ return createPortal(