Skip to content

Commit 78e3b67

Browse files
authored
Fix an issue where the AI Assistant input textbox sometimes swallows the first character of input. #9740
1 parent c8bd75c commit 78e3b67

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/en_US/release_notes_9_14.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ Bug fixes
3131
| `Issue #9279 <https://github.com/pgadmin-org/pgadmin4/issues/9279>`_ - Fixed an issue where OAuth2 authentication fails with 'object has no attribute' if OAUTH2_AUTO_CREATE_USER is False.
3232
| `Issue #9392 <https://github.com/pgadmin-org/pgadmin4/issues/9392>`_ - Ensure that the Geometry Viewer refreshes when re-running queries or switching geometry columns, preventing stale data from being displayed.
3333
| `Issue #9721 <https://github.com/pgadmin-org/pgadmin4/issues/9721>`_ - Fixed an issue where permissions page is not completely accessible on full scroll.
34+
| `Issue #9740 <https://github.com/pgadmin-org/pgadmin4/issues/9740>`_ - Fixed an issue where the AI Assistant input textbox sometimes swallows the first character of input.

web/pgadmin/tools/sqleditor/static/js/components/sections/NLQChatPanel.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ export function NLQChatPanel() {
288288
});
289289

290290
const messagesEndRef = useRef(null);
291+
const inputRef = useRef(null);
291292
const abortControllerRef = useRef(null);
292293
const readerRef = useRef(null);
293294
const stoppedRef = useRef(false);
@@ -366,6 +367,16 @@ export function NLQChatPanel() {
366367
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
367368
}, [messages]);
368369

370+
// Auto-focus the input when loading completes
371+
useEffect(() => {
372+
if (!isLoading) {
373+
// Defer focus to ensure the DOM has updated (disabled=false)
374+
setTimeout(() => {
375+
inputRef.current?.focus();
376+
}, 0);
377+
}
378+
}, [isLoading]);
379+
369380
// Force CodeMirror re-render when panel becomes visible (fixes tab switching issue)
370381
const [cmKey, setCmKey] = useState(0);
371382
useEffect(() => {
@@ -741,6 +752,7 @@ export function NLQChatPanel() {
741752

742753
<InputArea>
743754
<TextField
755+
inputRef={inputRef}
744756
fullWidth
745757
multiline
746758
minRows={1}

0 commit comments

Comments
 (0)