mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-14 04:08:32 +03:00
Fix 1 more esc clash
This commit is contained in:
parent
c35f4bb161
commit
0038c2225b
2 changed files with 15 additions and 2 deletions
|
@ -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;
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -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],
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue