Fix esc triggering exit confirmation when closing the expander

pull/79/head
Lim Chee Aun 2023-03-08 14:49:52 +08:00
rodzic 73b8294811
commit 4e5e2fa75f
1 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -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,