fix(settings): global comma shortcut works on all authenticated pages
This commit is contained in:
@@ -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()
|
||||||
|
}
|
||||||
|
if (e.key === 'Escape' && isOpen) {
|
||||||
|
closeSettings()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.addEventListener('keydown', handleEsc)
|
window.addEventListener('keydown', handler)
|
||||||
return () => window.removeEventListener('keydown', handleEsc)
|
return () => window.removeEventListener('keydown', handler)
|
||||||
}, [isOpen, closeSettings])
|
}, [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
|
||||||
|
|||||||
Reference in New Issue
Block a user