Skip to content

Commit 9ab0d07

Browse files
committed
fix: focus chat input when we are creating new session
1 parent 47fe343 commit 9ab0d07

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

custom/SessionsHistory.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"
77
>
88
<h3 :class="h3Style">{{ $t('Chat history') }}</h3>
9-
<Button @click="agentStore.createPreSession(); agentStore.setSessionHistoryOpen(false)" :disabled="agentStore.isResponseInProgress" class="w-[360px] mx-4 my-2 mb-4 rounded-3xl text-gray-800 dark:text-gray-200">
9+
<Button @click="agentStore.createPreSession(); agentStore.setSessionHistoryOpen(false); agentStore.focusTextInput();" :disabled="agentStore.isResponseInProgress" class="w-[360px] mx-4 my-2 mb-4 rounded-3xl text-gray-800 dark:text-gray-200">
1010
<IconPlusOutline class="w-5 h-5" />
1111
{{ $t('New chat') }}
1212
</Button>

custom/useAgentStore.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,14 @@ export const useAgentStore = defineStore('agent', () => {
155155
function openChat() {
156156
isChatOpen.value = true;
157157
nextTick(() => {
158-
textInput.value?.focus();
158+
focusTextInput();
159159
});
160160
}
161161

162+
function focusTextInput() {
163+
textInput.value?.focus();
164+
}
165+
162166
function setIsChatOpen(isOpen: boolean) {
163167
isOpen ? openChat() : closeChat();
164168
}
@@ -354,5 +358,6 @@ export const useAgentStore = defineStore('agent', () => {
354358
setIsTeleportedToBody,
355359
chatWidth,
356360
setChatWidth,
361+
focusTextInput
357362
}
358363
})

0 commit comments

Comments
 (0)