1
0
Fork 0

Fix 1 more esc clash

This commit is contained in:
Lim Chee Aun 2023-10-26 11:16:34 +08:00
parent c35f4bb161
commit 0038c2225b
2 changed files with 15 additions and 2 deletions

View file

@ -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;
},
},
);

View file

@ -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],
);