Check for lightbox also
This commit is contained in:
@@ -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])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user