From cae3b68c7f9cc61e0ed69c47fd0c059299589adb Mon Sep 17 00:00:00 2001 From: janderedev Date: Fri, 6 Aug 2021 18:07:11 +0200 Subject: [PATCH] ESC now removes the last attachment. Fixes #16 --- src/components/common/messaging/MessageBox.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/common/messaging/MessageBox.tsx b/src/components/common/messaging/MessageBox.tsx index 66a87bca..17b3eb2d 100644 --- a/src/components/common/messaging/MessageBox.tsx +++ b/src/components/common/messaging/MessageBox.tsx @@ -477,8 +477,21 @@ export default observer(({ channel }: Props) => { return send(); } - if (e.key === "Escape" && replies.length > 0) { - setReplies(replies.slice(0, -1)); + if (e.key === "Escape") { + if (replies.length > 0) { + setReplies(replies.slice(0, -1)); + } else if ( + uploadState.type === "attached" && + uploadState.files.length > 0 + ) { + setUploadState({ + type: + uploadState.files.length > 1 + ? "attached" + : "none", + files: uploadState.files.slice(0, -1), + }); + } } debouncedStopTyping(true);