From e3e9b214a936f498343dd78e7c6502a48720cd05 Mon Sep 17 00:00:00 2001 From: Kartikay Singh pundir <130781246+kartikay6969@users.noreply.github.com> Date: Sun, 15 Dec 2024 18:44:49 +0530 Subject: [PATCH] fix: keyboard shortcuts with alt keys in message composer --- .../room/composer/messageBox/MessageBox.tsx | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx b/apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx index 6546a6be92455..7c4d2028e0e03 100644 --- a/apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx +++ b/apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx @@ -217,31 +217,35 @@ const MessageBox = ({ } case 'ArrowUp': { - if (input.selectionEnd === 0) { + if (event.altKey) { event.preventDefault(); event.stopPropagation(); + input.setSelectionRange(0, 0); + return; + } + if (input.selectionEnd === 0) { + event.preventDefault(); + event.stopPropagation(); onNavigateToPreviousMessage?.(); - - if (event.altKey) { - input.setSelectionRange(0, 0); - } } - return; } case 'ArrowDown': { - if (input.selectionEnd === input.value.length) { + if (event.altKey) { event.preventDefault(); event.stopPropagation(); + input.setSelectionRange(input.value.length, input.value.length); + return; + } + if (input.selectionEnd === input.value.length) { + event.preventDefault(); + event.stopPropagation(); onNavigateToNextMessage?.(); - - if (event.altKey) { - input.setSelectionRange(input.value.length, input.value.length); - } } + return; } }