Skip to content
10 changes: 10 additions & 0 deletions src/components/ai/AiChatDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@
sendMessage()
}

const setUserInput = (value: string): void => {
userInput.value = value
nextTick(() => {
autoResize()
textareaRef.value?.focus()
})
}

defineExpose({ setUserInput })

const clearMessage = (): void => {
abortController.value.abort()
abortController.value = new AbortController()
Expand Down
11 changes: 8 additions & 3 deletions src/components/layout/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
<div class="modal-body row">
<Suspense>
<AiChatDialog
ref="aiChatDialog"
:randomAiQuestions
@close="closeAiDialog"
@backToSearch="backToSearch"
Expand Down Expand Up @@ -322,9 +323,13 @@
this.selectedIndex = null
this.selectedItem = null
},
focusSearchAi() {
document.querySelector("#ai-chat-input").value = ""
document.querySelector("#ai-chat-input").focus()
focusSearchAi(event) {
const openedFromSearch =
event?.relatedTarget?.closest("#search-modal")
const prefill = openedFromSearch
? this.searchValue?.trim() || ""
: ""
this.$refs.aiChatDialog?.setUserInput(prefill)
},
onHiddenAi() {},
search(value) {
Expand Down
Loading