Skip to content

Commit

Permalink
fix: implement proper handling of Tab inside the textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
luka-hash committed Feb 16, 2025
1 parent eda10b1 commit a7c3d17
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/components/chat/BaseChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
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;
Expand Down

0 comments on commit a7c3d17

Please sign in to comment.