diff --git a/src/components/compose.jsx b/src/components/compose.jsx index e4fcf69c..14d2990a 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -387,6 +387,14 @@ function Compose({ enableOnFormTags: true, // Use keyup because Esc keydown will close the confirm dialog on Safari keyup: true, + ignoreEventWhen: (e) => { + const modals = document.querySelectorAll('#modal-container > *'); + const hasModal = !!modals; + const hasOnlyComposer = + modals.length === 1 && modals[0].querySelector('#compose-container'); + console.log('hasModal', hasModal, 'hasOnlyComposer', hasOnlyComposer); + return hasModal && !hasOnlyComposer; + }, }, ); diff --git a/src/components/modal.jsx b/src/components/modal.jsx index dfe7b535..d9ba635d 100644 --- a/src/components/modal.jsx +++ b/src/components/modal.jsx @@ -22,12 +22,17 @@ function Modal({ children, onClose, onClick, class: className }) { const escRef = useHotkeys( 'esc', - onClose, + () => { + setTimeout(() => { + onClose?.(); + }, 0); + }, { enabled: !!onClose, + // Using keyup and setTimeout above + // This will run "later" to prevent clash with esc handlers from other components keydown: false, keyup: true, - // This will run "later" to prevent clash with esc handlers from other components }, [onClose], );