diff --git a/web/modals/modal.react.js b/web/modals/modal.react.js --- a/web/modals/modal.react.js +++ b/web/modals/modal.react.js @@ -31,10 +31,18 @@ withCloseButton = true, } = props; const overlayRef = React.useRef(); + const firstClickRef = React.useRef(null); - const onBackgroundClick = React.useCallback( + const onBackgroundMouseDown = React.useCallback(event => { + firstClickRef.current = event.target; + }, []); + + const onBackgroundMouseUp = React.useCallback( event => { - if (event.target === overlayRef.current) { + if ( + event.target === overlayRef.current && + firstClickRef.current === overlayRef.current + ) { onClose(); } }, @@ -87,7 +95,8 @@