diff --git a/docs/app/components/content/AssistantDemo.vue b/docs/app/components/content/AssistantDemo.vue index 31ac93144..482f3c726 100644 --- a/docs/app/components/content/AssistantDemo.vue +++ b/docs/app/components/content/AssistantDemo.vue @@ -148,6 +148,7 @@ function resetChat() { :disabled="!isEnabled" :placeholder="t('assistant.askAnything')" variant="subtle" + :autofocus="false" size="sm" @submit="handleSubmit" > diff --git a/layer/modules/assistant/runtime/components/AssistantPanel.vue b/layer/modules/assistant/runtime/components/AssistantPanel.vue index 5c4d77a0e..8df121958 100644 --- a/layer/modules/assistant/runtime/components/AssistantPanel.vue +++ b/layer/modules/assistant/runtime/components/AssistantPanel.vue @@ -23,6 +23,12 @@ const open = computed({ }, }) +const promptRef = ref<{ textareaRef?: HTMLTextAreaElement } | null>(null) +watch(open, (value) => { + if (!value) return + nextTick(() => promptRef.value?.textareaRef?.focus({ preventScroll: true })) +}) + const displayTitle = computed(() => t('assistant.title')) const displayPlaceholder = computed(() => t('assistant.placeholder')) @@ -273,6 +279,7 @@ defineShortcuts({