diff --git a/src/components/datemodal.jsx b/src/components/datemodal.jsx index dff3631..1609a34 100644 --- a/src/components/datemodal.jsx +++ b/src/components/datemodal.jsx @@ -16,10 +16,12 @@ export default forwardRef(function DateModal({ onDate, initialDate, onClose }, r } useOutsideAlerter(wrapperRef, () => { - if (typeof onClose == "function") { - onClose(); + if (!open) { + if (typeof onClose == "function") { + onClose(); + } + setOpen(false); } - setOpen(false); }); return ( diff --git a/src/components/task.jsx b/src/components/task.jsx index 85eded8..404d117 100644 --- a/src/components/task.jsx +++ b/src/components/task.jsx @@ -34,7 +34,11 @@ export default function Task( { task, initialFocus, onFocusChange } ) { const wrapperRef = useRef(null); const cm = useRef(null); - useOutsideAlerter(wrapperRef, () => setHasFocus(false)); + useOutsideAlerter(wrapperRef, () => { + if (!hasFocus) { + setHasFocus(false); + } + }); useEffect(() => { if (typeof onFocusChange == "function") onFocusChange(hasFocus);