Fix esc triggering exit confirmation when closing the expander

This commit is contained in:
Lim Chee Aun 2023-03-08 14:49:52 +08:00
parent 73b8294811
commit 4e5e2fa75f

View file

@ -348,12 +348,24 @@ function Compose({
};
useEffect(updateCharCount, []);
const escDownRef = useRef(false);
useHotkeys(
'esc',
() => {
if (!standalone && confirmClose()) {
escDownRef.current = true;
// This won't be true if this event is already handled and not propagated 🤞
},
{
enableOnFormTags: true,
},
);
useHotkeys(
'esc',
() => {
if (!standalone && escDownRef.current && confirmClose()) {
onClose();
}
escDownRef.current = false;
},
{
enableOnFormTags: true,