Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions chat/src/components/message-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ export default function MessageInput({
return () => clearInterval(interval);
}, [sentChars]);

// Autofocus on the message input box on user's turn
useEffect(() => {
if (
serverStatus === "stable" &&
!disabled &&
inputMode === "text" &&
textareaRef.current
) {
textareaRef.current.focus();
}
}, [serverStatus, disabled, inputMode]);

const addSentChar = (char: string) => {
const newChar: SentChar = {
char,
Expand Down Expand Up @@ -332,20 +344,20 @@ export default function MessageInput({
);
}

function Char({ char }: { char: string }) {
function Char({char}: { char: string }) {
switch (char) {
case "ArrowUp":
return <ArrowUpIcon className="h-4 w-4" />;
return <ArrowUpIcon className="h-4 w-4"/>;
case "ArrowDown":
return <ArrowDownIcon className="h-4 w-4" />;
return <ArrowDownIcon className="h-4 w-4"/>;
case "ArrowRight":
return <ArrowRightIcon className="h-4 w-4" />;
return <ArrowRightIcon className="h-4 w-4"/>;
case "ArrowLeft":
return <ArrowLeftIcon className="h-4 w-4" />;
return <ArrowLeftIcon className="h-4 w-4"/>;
case "⏎":
return <CornerDownLeftIcon className="h-4 w-4" />;
return <CornerDownLeftIcon className="h-4 w-4"/>;
case "Backspace":
return <DeleteIcon className="h-4 w-4" />;
return <DeleteIcon className="h-4 w-4"/>;
default:
return char;
}
Expand Down