Check for drawer

This commit is contained in:
Eric Bailey
2024-09-13 17:50:02 -05:00
parent 3361e96e85
commit dabb5efe2d
@@ -3,6 +3,7 @@ import React from 'react'
import {useDialogStateContext} from '#/state/dialogs' import {useDialogStateContext} from '#/state/dialogs'
import {useLightbox} from '#/state/lightbox' import {useLightbox} from '#/state/lightbox'
import {useModals} from '#/state/modals' import {useModals} from '#/state/modals'
import {useIsDrawerOpen} from '#/state/shell/drawer-open'
import {useComposerControls} from './' import {useComposerControls} from './'
/** /**
@@ -41,11 +42,17 @@ export function useComposerKeyboardShortcut() {
const {openDialogs} = useDialogStateContext() const {openDialogs} = useDialogStateContext()
const {isModalActive} = useModals() const {isModalActive} = useModals()
const {activeLightbox} = useLightbox() const {activeLightbox} = useLightbox()
const isDrawerOpen = useIsDrawerOpen()
React.useEffect(() => { React.useEffect(() => {
function handler(event: KeyboardEvent) { function handler(event: KeyboardEvent) {
if (shouldIgnore(event)) return if (shouldIgnore(event)) return
if (openDialogs.current.size > 0 || isModalActive || activeLightbox) if (
openDialogs.current.size > 0 ||
isModalActive ||
activeLightbox ||
isDrawerOpen
)
return return
if (event.key === 'n' || event.key === 'N') { if (event.key === 'n' || event.key === 'N') {
openComposer({}) openComposer({})
@@ -53,5 +60,5 @@ export function useComposerKeyboardShortcut() {
} }
document.addEventListener('keydown', handler) document.addEventListener('keydown', handler)
return () => document.removeEventListener('keydown', handler) return () => document.removeEventListener('keydown', handler)
}, [openComposer, isModalActive, openDialogs, activeLightbox]) }, [openComposer, isModalActive, openDialogs, activeLightbox, isDrawerOpen])
} }