Check for lightbox also

This commit is contained in:
Eric Bailey
2024-09-13 17:46:00 -05:00
parent 776141498a
commit 3361e96e85
@@ -1,6 +1,7 @@
import React from 'react'
import {useDialogStateContext} from '#/state/dialogs'
import {useLightbox} from '#/state/lightbox'
import {useModals} from '#/state/modals'
import {useComposerControls} from './'
@@ -39,16 +40,18 @@ export function useComposerKeyboardShortcut() {
const {openComposer} = useComposerControls()
const {openDialogs} = useDialogStateContext()
const {isModalActive} = useModals()
const {activeLightbox} = useLightbox()
React.useEffect(() => {
function handler(event: KeyboardEvent) {
if (shouldIgnore(event)) return
if (openDialogs.current.size > 0 || isModalActive) return
if (openDialogs.current.size > 0 || isModalActive || activeLightbox)
return
if (event.key === 'n' || event.key === 'N') {
openComposer({})
}
}
document.addEventListener('keydown', handler)
return () => document.removeEventListener('keydown', handler)
}, [openComposer, isModalActive, openDialogs])
}, [openComposer, isModalActive, openDialogs, activeLightbox])
}