Skip to content

Commit a7c3d17

Browse files
committed
fix: implement proper handling of Tab inside the textarea
1 parent eda10b1 commit a7c3d17

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

app/components/chat/BaseChat.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
112112
ref={textareaRef}
113113
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`}
114114
onKeyDown={(event) => {
115+
if (event.key === 'Tab') {
116+
event.preventDefault();
117+
const idx = event.target.selectionStart;
118+
if (idx !== null) {
119+
const start = event.target.value.substring(0, idx);
120+
const back = event.target.value.substring(idx);
121+
event.target.value = `${start} ${back}`;
122+
event.target.setSelectionRange(idx + 4, idx + 4);
123+
}
124+
return;
125+
}
115126
if (event.key === 'Enter') {
116127
if (event.shiftKey) {
117128
return;

0 commit comments

Comments
 (0)