From 48c34ef2bd117a86653af562906760dd8f88053c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 11 Jan 2026 03:26:56 +0000 Subject: [PATCH] fix: Prevent reset progress dialog from closing before action completes The click-outside handler was using mousedown which fires before click. When clicking the confirm button, the handler would close the dialog before the click event could trigger handleConfirmReset, preventing the reset from executing. Added a ref to the confirmation dialog and updated the click-outside handler to also check if clicks occur inside the dialog. --- components/Navbar.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/Navbar.tsx b/components/Navbar.tsx index e8f5f41..444b0ee 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -12,11 +12,16 @@ export default function Navbar() { const [settingsOpen, setSettingsOpen] = useState(false); const [showResetConfirm, setShowResetConfirm] = useState(false); const settingsRef = useRef(null); + const confirmDialogRef = useRef(null); // Close settings menu when clicking outside useEffect(() => { function handleClickOutside(event: MouseEvent) { - if (settingsRef.current && !settingsRef.current.contains(event.target as Node)) { + const target = event.target as Node; + const isInsideSettings = settingsRef.current?.contains(target); + const isInsideConfirmDialog = confirmDialogRef.current?.contains(target); + + if (!isInsideSettings && !isInsideConfirmDialog) { setSettingsOpen(false); setShowResetConfirm(false); } @@ -202,6 +207,7 @@ export default function Navbar() { {/* Reset Progress Confirmation Dialog */} {showResetConfirm && (