forked from open-webui/open-webui
feat: chat input focus on new chat
This commit is contained in:
parent
1d4d1ddbea
commit
260a8b8b83
4 changed files with 16 additions and 8 deletions
|
@ -293,6 +293,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
const chatInput = document.getElementById('chat-textarea');
|
||||||
|
window.setTimeout(() => chatInput?.focus(), 0);
|
||||||
|
|
||||||
const dropZone = document.querySelector('body');
|
const dropZone = document.querySelector('body');
|
||||||
|
|
||||||
const onDragOver = (e) => {
|
const onDragOver = (e) => {
|
||||||
|
|
|
@ -101,17 +101,16 @@
|
||||||
: 'invisible'}"
|
: 'invisible'}"
|
||||||
>
|
>
|
||||||
<div class="px-2 flex justify-center space-x-2">
|
<div class="px-2 flex justify-center space-x-2">
|
||||||
<button
|
<a
|
||||||
id="sidebar-new-chat-button"
|
id="sidebar-new-chat-button"
|
||||||
class="flex-grow flex justify-between rounded-xl px-3.5 py-2 hover:bg-gray-900 transition"
|
class="flex-grow flex justify-between rounded-xl px-3.5 py-2 hover:bg-gray-900 transition"
|
||||||
|
href="/"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
goto('/');
|
await goto('/');
|
||||||
|
|
||||||
const newChatButton = document.getElementById('new-chat-button');
|
const newChatButton = document.getElementById('new-chat-button');
|
||||||
|
setTimeout(() => {
|
||||||
if (newChatButton) {
|
newChatButton?.click();
|
||||||
newChatButton.click();
|
}, 0);
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="flex self-center">
|
<div class="flex self-center">
|
||||||
|
@ -141,7 +140,7 @@
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if $user?.role === 'admin'}
|
{#if $user?.role === 'admin'}
|
||||||
|
|
|
@ -134,6 +134,9 @@
|
||||||
settings.set({
|
settings.set({
|
||||||
..._settings
|
..._settings
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const chatInput = document.getElementById('chat-textarea');
|
||||||
|
setTimeout(() => chatInput?.focus(), 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
|
|
|
@ -99,6 +99,9 @@
|
||||||
if (await loadChat()) {
|
if (await loadChat()) {
|
||||||
await tick();
|
await tick();
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
|
const chatInput = document.getElementById('chat-textarea');
|
||||||
|
chatInput?.focus();
|
||||||
} else {
|
} else {
|
||||||
await goto('/');
|
await goto('/');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue