diff --git a/src/components/modal.jsx b/src/components/modal.jsx index 2fc00fba..dfe7b535 100644 --- a/src/components/modal.jsx +++ b/src/components/modal.jsx @@ -20,9 +20,17 @@ function Modal({ children, onClose, onClick, class: className }) { return () => clearTimeout(timer); }, []); - const escRef = useHotkeys('esc', onClose, [onClose], { - enabled: !!onClose, - }); + const escRef = useHotkeys( + 'esc', + onClose, + { + enabled: !!onClose, + keydown: false, + keyup: true, + // This will run "later" to prevent clash with esc handlers from other components + }, + [onClose], + ); const Modal = (
{ + const hasModal = !!document.querySelector('#modal-container > *'); + return hasModal; + }, }, ); // For backspace, will always close both media and status page