fix(settings): global comma shortcut works on all authenticated pages

This commit is contained in:
Usman Baig
2026-03-24 17:05:21 +01:00
parent e12a3661fa
commit c48023be9f

View File

@@ -216,7 +216,7 @@ function TabContent({
// ─── Main Modal ───────────────────────────────────────────────── // ─── Main Modal ─────────────────────────────────────────────────
export default function UnifiedSettingsModal() { export default function UnifiedSettingsModal() {
const { isOpen, closeUnifiedSettings: closeSettings, initialTab: initTab } = useUnifiedSettings() const { isOpen, openUnifiedSettings, closeUnifiedSettings: closeSettings, initialTab: initTab } = useUnifiedSettings()
const { user } = useAuth() const { user } = useAuth()
const [context, setContext] = useState<SettingsContext>('site') const [context, setContext] = useState<SettingsContext>('site')
@@ -262,15 +262,24 @@ export default function UnifiedSettingsModal() {
}).catch(() => {}) }).catch(() => {})
}, [isOpen, user?.org_id]) }, [isOpen, user?.org_id])
// Escape key closes // Global keyboard shortcuts: `,` toggles settings, Escape closes
useEffect(() => { useEffect(() => {
if (!isOpen) return const handler = (e: KeyboardEvent) => {
const handleEsc = (e: KeyboardEvent) => { const tag = (e.target as HTMLElement)?.tagName
if (e.key === 'Escape') closeSettings() if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return
if (e.key === ',' && !e.metaKey && !e.ctrlKey && !e.altKey) {
e.preventDefault()
if (isOpen) closeSettings()
else openUnifiedSettings()
} }
window.addEventListener('keydown', handleEsc) if (e.key === 'Escape' && isOpen) {
return () => window.removeEventListener('keydown', handleEsc) closeSettings()
}, [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 tabs = context === 'site' ? SITE_TABS : context === 'workspace' ? WORKSPACE_TABS : ACCOUNT_TABS
const activeTab = context === 'site' ? siteTabs : context === 'workspace' ? workspaceTabs : accountTabs const activeTab = context === 'site' ? siteTabs : context === 'workspace' ? workspaceTabs : accountTabs