Add cancel edit-message on Escape Key press (#765)
authorjameskitt616 <52933658+jameskitt616@users.noreply.github.com>
Sat, 20 Aug 2022 13:26:37 +0000 (15:26 +0200)
committerGitHub <noreply@github.com>
Sat, 20 Aug 2022 13:26:37 +0000 (18:56 +0530)
src/app/molecules/message/Message.jsx

index 1e5a006eb9876e663033b8d2ef18b6f625bc1f1e..42344d7522fe6dfef1615a15faa8d4bac547774d 100644 (file)
@@ -290,6 +290,11 @@ function MessageEdit({ body, onSave, onCancel }) {
   }, []);
 
   const handleKeyDown = (e) => {
+    if (e.key === 'Escape') {
+      e.preventDefault();
+      onCancel();
+    }
+
     if (e.key === 'Enter' && e.shiftKey === false) {
       e.preventDefault();
       onSave(editInputRef.current.value);