Skip to content

Commit

Permalink
[core] Cleanup Modal code
Browse files Browse the repository at this point in the history
  • Loading branch information
rtivital committed Nov 12, 2022
1 parent 17f8aa5 commit 6eee7c8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/mantine-core/src/Modal/Modal.tsx
Expand Up @@ -208,14 +208,15 @@ export function Modal(props: ModalProps) {
useFocusReturn({ opened, shouldReturnFocus: trapFocus && withFocusReturn });

const clickTarget = useRef<EventTarget>(null);

useWindowEvent('mousedown', (e) => {
clickTarget.current = e.target;
});

const handleOutsideClick = () => {
if (clickTarget.current !== overlayRef.current) return;

closeOnClickOutside && onClose();
if (clickTarget.current === overlayRef.current) {
closeOnClickOutside && onClose();
}
};

return (
Expand Down

0 comments on commit 6eee7c8

Please sign in to comment.