Esc for compose field

This commit is contained in:
Lim Chee Aun 2023-01-01 19:41:42 +08:00
parent d2d8571b3f
commit 0d92f65f7e

View file

@ -2,6 +2,7 @@ import './compose.css';
import '@github/text-expander-element';
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import stringLength from 'string-length';
import supportedLanguages from '../data/status-supported-languages';
@ -445,6 +446,18 @@ function Compose({
setCharCount(getCharCount());
};
useHotkeys(
'esc',
() => {
if (!standalone && confirmClose()) {
onClose();
}
},
{
enableOnFormTags: true,
},
);
return (
<div id="compose-container" class={standalone ? 'standalone' : ''}>
<div class="compose-top">