mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-28 20:28:52 +03:00
Fix 'esc' closes both modal and status page
This commit is contained in:
parent
c03f39b10c
commit
81644e67bb
2 changed files with 15 additions and 3 deletions
|
@ -20,9 +20,17 @@ function Modal({ children, onClose, onClick, class: className }) {
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const escRef = useHotkeys('esc', onClose, [onClose], {
|
const escRef = useHotkeys(
|
||||||
enabled: !!onClose,
|
'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 Modal = (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -537,6 +537,10 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
|
||||||
// If media is open, esc to close media first
|
// If media is open, esc to close media first
|
||||||
// Else close the status page
|
// Else close the status page
|
||||||
enabled: !showMedia,
|
enabled: !showMedia,
|
||||||
|
ignoreEventWhen: (e) => {
|
||||||
|
const hasModal = !!document.querySelector('#modal-container > *');
|
||||||
|
return hasModal;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
// For backspace, will always close both media and status page
|
// For backspace, will always close both media and status page
|
||||||
|
|
Loading…
Reference in a new issue