From 21bdaa1516223cfa90194827f6d3a0b7d34ff941 Mon Sep 17 00:00:00 2001 From: Paul Carroll Date: Fri, 8 Aug 2025 17:03:20 -0400 Subject: [PATCH] linting fixes --- .../RefreshGuardModal/RefreshGuardModal.tsx | 4 ++-- webclient/src/hooks/useNavigationGuard.ts | 20 +++++++++++++------ webclient/src/hooks/useRefreshGuard.ts | 10 +++++----- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/webclient/src/components/RefreshGuardModal/RefreshGuardModal.tsx b/webclient/src/components/RefreshGuardModal/RefreshGuardModal.tsx index 7c9c52ded..d95c22f4a 100644 --- a/webclient/src/components/RefreshGuardModal/RefreshGuardModal.tsx +++ b/webclient/src/components/RefreshGuardModal/RefreshGuardModal.tsx @@ -42,7 +42,7 @@ export const RefreshGuardModal: React.FC = ({ aria-describedby="refresh-guard-description" maxWidth="sm" fullWidth - disableEscapeKeyDown // Prevent closing with Escape key + disableEscapeKeyDown > @@ -69,7 +69,7 @@ export const RefreshGuardModal: React.FC = ({ onClick={onClose} variant="contained" color="primary" - autoFocus // Focus the safe option by default + autoFocus > {cancelButtonText} diff --git a/webclient/src/hooks/useNavigationGuard.ts b/webclient/src/hooks/useNavigationGuard.ts index 851afc049..8a6f7fe83 100644 --- a/webclient/src/hooks/useNavigationGuard.ts +++ b/webclient/src/hooks/useNavigationGuard.ts @@ -26,7 +26,7 @@ interface UseNavigationGuardReturn { export const useNavigationGuard = ({ shouldGuard, message = 'You have unsaved changes that will be lost.', - onBeforeNavigate + onBeforeNavigate, }: UseNavigationGuardOptions): UseNavigationGuardReturn => { const [showModal, setShowModal] = useState(false); const [pendingLocation, setPendingLocation] = useState(null); @@ -40,7 +40,10 @@ export const useNavigationGuard = ({ location = useLocation(); } catch (error) { // React Router hooks not available - navigation guard will be disabled - console.warn('React Router not available, navigation guard disabled:', error); + console.warn( + 'React Router not available, navigation guard disabled:', + error + ); } const handleConfirmNavigation = useCallback(() => { @@ -58,7 +61,7 @@ export const useNavigationGuard = ({ useEffect(() => { if (!shouldGuard || !location || !navigate) { - return; // Skip navigation guard if Router is not available + return; } const handleLinkClick = (event: Event) => { @@ -70,8 +73,13 @@ export const useNavigationGuard = ({ } const href = link.getAttribute('href'); - if (!href || href.startsWith('#') || href.startsWith('http') || href.startsWith('mailto:')) { - return; // Allow external links, anchors, and mailto links + if ( + !href || + href.startsWith('#') || + href.startsWith('http') || + href.startsWith('mailto:') + ) { + return; } // Check if this is a React Router navigation @@ -129,6 +137,6 @@ export const useNavigationGuard = ({ pendingLocation, handleConfirmNavigation, handleCancelNavigation, - guardMessage: message + guardMessage: message, }; }; diff --git a/webclient/src/hooks/useRefreshGuard.ts b/webclient/src/hooks/useRefreshGuard.ts index 7eeb5b661..0b3018c8f 100644 --- a/webclient/src/hooks/useRefreshGuard.ts +++ b/webclient/src/hooks/useRefreshGuard.ts @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react'; interface UseRefreshGuardOptions { shouldGuard: boolean; message?: string; - onUnload?: () => void; // Called only when page is actually unloading (not on beforeunload) + onUnload?: () => void; } interface UseRefreshGuardReturn { @@ -22,7 +22,7 @@ interface UseRefreshGuardReturn { export const useRefreshGuard = ({ shouldGuard, message = 'You have unsaved changes that will be lost.', - onUnload + onUnload, }: UseRefreshGuardOptions): UseRefreshGuardReturn => { const [showModal, setShowModal] = useState(false); @@ -34,7 +34,7 @@ export const useRefreshGuard = ({ // Show browser's native dialog first event.preventDefault(); - event.returnValue = ''; // Required for Chrome + event.returnValue = ''; // Schedule custom modal to show after browser dialog is dismissed // This only happens if user chooses "Stay" on the browser dialog @@ -44,7 +44,7 @@ export const useRefreshGuard = ({ } }, 100); - return ''; // Required for other browsers + return ''; }; const handleUnload = () => { @@ -76,6 +76,6 @@ export const useRefreshGuard = ({ return { showModal, setShowModal, - guardMessage: message + guardMessage: message, }; };