fix: keep input focus during generation (#10679)

This commit is contained in:
David Luzar
2026-01-20 20:14:28 +01:00
committed by GitHub
parent 9ba0f5dbc9
commit 3c8e893cab
2 changed files with 16 additions and 4 deletions
@@ -90,7 +90,9 @@ export const ChatInterface = ({
const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => { const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (event.key === KEYS.ENTER && !event.shiftKey) { if (event.key === KEYS.ENTER && !event.shiftKey) {
event.preventDefault(); event.preventDefault();
handleSubmit(); if (!isGenerating) {
handleSubmit();
}
} }
}; };
@@ -143,7 +145,14 @@ export const ChatInterface = ({
<div className="chat-interface__input-container"> <div className="chat-interface__input-container">
<div className="chat-interface__input-outer"> <div className="chat-interface__input-outer">
<div className="chat-interface__input-wrapper"> <div
className="chat-interface__input-wrapper"
style={{
borderColor: isGenerating
? "var(--dialog-border-color)"
: undefined,
}}
>
<textarea <textarea
ref={textareaRef} ref={textareaRef}
autoFocus autoFocus
@@ -152,13 +161,15 @@ export const ChatInterface = ({
onChange={handleInputChange} onChange={handleInputChange}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
placeholder={ placeholder={
rateLimits?.rateLimitRemaining === 0 isGenerating
? t("chat.generating")
: rateLimits?.rateLimitRemaining === 0
? t("chat.rateLimit.messageLimitInputPlaceholder") ? t("chat.rateLimit.messageLimitInputPlaceholder")
: messages.length > 0 : messages.length > 0
? t("chat.inputPlaceholderWithMessages") ? t("chat.inputPlaceholderWithMessages")
: t("chat.inputPlaceholder", { shortcut: "Shift + Enter" }) : t("chat.inputPlaceholder", { shortcut: "Shift + Enter" })
} }
disabled={isGenerating || rateLimits?.rateLimitRemaining === 0} disabled={rateLimits?.rateLimitRemaining === 0}
rows={1} rows={1}
cols={30} cols={30}
onInput={onInput} onInput={onInput}
+1
View File
@@ -623,6 +623,7 @@
"chat": { "chat": {
"inputPlaceholder": "Start typing your diagram idea here... ({{shortcut}} for new line)", "inputPlaceholder": "Start typing your diagram idea here... ({{shortcut}} for new line)",
"inputPlaceholderWithMessages": "Continue refining your diagram...", "inputPlaceholderWithMessages": "Continue refining your diagram...",
"generating": "Generating...",
"rateLimitRemaining": "{{count}} requests left today", "rateLimitRemaining": "{{count}} requests left today",
"role": { "role": {
"user": "You", "user": "You",