Skip to content

Commit aa42948

Browse files
authored
fix(assistant): autofocus behaviour (#1406)
1 parent 0e143e6 commit aa42948

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

docs/app/components/content/AssistantDemo.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ function resetChat() {
148148
:disabled="!isEnabled"
149149
:placeholder="t('assistant.askAnything')"
150150
variant="subtle"
151+
:autofocus="false"
151152
size="sm"
152153
@submit="handleSubmit"
153154
>

layer/modules/assistant/runtime/components/AssistantPanel.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ const open = computed({
2323
},
2424
})
2525
26+
const promptRef = ref<{ textareaRef?: HTMLTextAreaElement } | null>(null)
27+
watch(open, (value) => {
28+
if (!value) return
29+
nextTick(() => promptRef.value?.textareaRef?.focus({ preventScroll: true }))
30+
})
31+
2632
const displayTitle = computed(() => t('assistant.title'))
2733
const displayPlaceholder = computed(() => t('assistant.placeholder'))
2834
@@ -273,6 +279,7 @@ defineShortcuts({
273279

274280
<template #footer>
275281
<UChatPrompt
282+
ref="promptRef"
276283
v-model="input"
277284
:error="chat.error"
278285
:placeholder="displayPlaceholder"

0 commit comments

Comments
 (0)