From a7c3d1706c51be3e1e18fada687f6d6ddb7ddc61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Ivanovi=C4=87?= Date: Sun, 16 Feb 2025 22:15:29 +0100 Subject: [PATCH] fix: implement proper handling of Tab inside the textarea --- app/components/chat/BaseChat.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index c4f90f43a1..e2ae890b19 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -112,6 +112,17 @@ export const BaseChat = React.forwardRef( ref={textareaRef} className={`w-full pl-4 pt-4 pr-16 focus:outline-none resize-none text-md text-bolt-elements-textPrimary placeholder-bolt-elements-textTertiary bg-transparent`} onKeyDown={(event) => { + if (event.key === 'Tab') { + event.preventDefault(); + const idx = event.target.selectionStart; + if (idx !== null) { + const start = event.target.value.substring(0, idx); + const back = event.target.value.substring(idx); + event.target.value = `${start} ${back}`; + event.target.setSelectionRange(idx + 4, idx + 4); + } + return; + } if (event.key === 'Enter') { if (event.shiftKey) { return;