Skip to content

Commit ffc8f0f

Browse files
authored
Merge pull request #1557 from SoftUni-Internal/1669-focus-is-removed-from-input-in-ai-mentor-when-enter-is-clicked
The text field's focus is maintained after a message is sent.
2 parents ac29c94 + dcf3f54 commit ffc8f0f

File tree

1 file changed

+3
-1
lines changed
  • Servers/UI/OJS.Servers.Ui/ClientApp/src/components/mentor

1 file changed

+3
-1
lines changed

Servers/UI/OJS.Servers.Ui/ClientApp/src/components/mentor/Mentor.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const Mentor = (props: IMentorProps) => {
4747
problemId: -1,
4848
},
4949
]);
50+
const inputRef = useRef<HTMLInputElement>(null);
5051
const messagesEndRef = useRef<HTMLDivElement>(null);
5152

5253
const [ startConversation, { data: conversationData, error, isLoading } ] = useStartConversationMutation();
@@ -141,6 +142,7 @@ const Mentor = (props: IMentorProps) => {
141142
});
142143

143144
setInputMessage('');
145+
inputRef.current?.focus();
144146
};
145147

146148
const handleKeyPress = (e: React.KeyboardEvent) => {
@@ -277,13 +279,13 @@ const Mentor = (props: IMentorProps) => {
277279
fullWidth
278280
multiline
279281
maxRows={4}
282+
inputRef={inputRef}
280283
value={inputMessage}
281284
onChange={(e) => setInputMessage(e.target.value)}
282285
onKeyDown={handleKeyPress}
283286
placeholder="Напишете вашето съобщение..."
284287
variant="standard"
285288
size="small"
286-
disabled={isLoading}
287289
className={styles.typingField}
288290
/>
289291
<div className={styles.sendButtonContainer}>

0 commit comments

Comments
 (0)