File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,11 +12,16 @@ export default function Navbar() {
1212 const [ settingsOpen , setSettingsOpen ] = useState ( false ) ;
1313 const [ showResetConfirm , setShowResetConfirm ] = useState ( false ) ;
1414 const settingsRef = useRef < HTMLDivElement > ( null ) ;
15+ const confirmDialogRef = useRef < HTMLDivElement > ( null ) ;
1516
1617 // Close settings menu when clicking outside
1718 useEffect ( ( ) => {
1819 function handleClickOutside ( event : MouseEvent ) {
19- if ( settingsRef . current && ! settingsRef . current . contains ( event . target as Node ) ) {
20+ const target = event . target as Node ;
21+ const isInsideSettings = settingsRef . current ?. contains ( target ) ;
22+ const isInsideConfirmDialog = confirmDialogRef . current ?. contains ( target ) ;
23+
24+ if ( ! isInsideSettings && ! isInsideConfirmDialog ) {
2025 setSettingsOpen ( false ) ;
2126 setShowResetConfirm ( false ) ;
2227 }
@@ -202,6 +207,7 @@ export default function Navbar() {
202207 { /* Reset Progress Confirmation Dialog */ }
203208 { showResetConfirm && (
204209 < div
210+ ref = { confirmDialogRef }
205211 className = "fixed inset-0 z-[100] flex items-center justify-center"
206212 role = "dialog"
207213 aria-modal = "true"
You can’t perform that action at this time.
0 commit comments