From c48023be9f64fc06242994c811c53c90edd8b48e Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Tue, 24 Mar 2026 17:05:21 +0100 Subject: [PATCH] fix(settings): global comma shortcut works on all authenticated pages --- .../settings/unified/UnifiedSettingsModal.tsx | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/components/settings/unified/UnifiedSettingsModal.tsx b/components/settings/unified/UnifiedSettingsModal.tsx index ccb7662..3df756d 100644 --- a/components/settings/unified/UnifiedSettingsModal.tsx +++ b/components/settings/unified/UnifiedSettingsModal.tsx @@ -216,7 +216,7 @@ function TabContent({ // ─── Main Modal ───────────────────────────────────────────────── export default function UnifiedSettingsModal() { - const { isOpen, closeUnifiedSettings: closeSettings, initialTab: initTab } = useUnifiedSettings() + const { isOpen, openUnifiedSettings, closeUnifiedSettings: closeSettings, initialTab: initTab } = useUnifiedSettings() const { user } = useAuth() const [context, setContext] = useState('site') @@ -262,15 +262,24 @@ export default function UnifiedSettingsModal() { }).catch(() => {}) }, [isOpen, user?.org_id]) - // Escape key closes + // Global keyboard shortcuts: `,` toggles settings, Escape closes useEffect(() => { - if (!isOpen) return - const handleEsc = (e: KeyboardEvent) => { - if (e.key === 'Escape') closeSettings() + const handler = (e: KeyboardEvent) => { + const tag = (e.target as HTMLElement)?.tagName + if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return + + if (e.key === ',' && !e.metaKey && !e.ctrlKey && !e.altKey) { + e.preventDefault() + if (isOpen) closeSettings() + else openUnifiedSettings() + } + if (e.key === 'Escape' && isOpen) { + closeSettings() + } } - window.addEventListener('keydown', handleEsc) - return () => window.removeEventListener('keydown', handleEsc) - }, [isOpen, closeSettings]) + window.addEventListener('keydown', handler) + return () => window.removeEventListener('keydown', handler) + }, [isOpen, openUnifiedSettings, closeSettings]) const tabs = context === 'site' ? SITE_TABS : context === 'workspace' ? WORKSPACE_TABS : ACCOUNT_TABS const activeTab = context === 'site' ? siteTabs : context === 'workspace' ? workspaceTabs : accountTabs