Merge pull request #941 from jannikstdl/autofocus-chat

fix: added focus selector
This commit is contained in:
Timothy Jaeryang Baek 2024-02-27 22:59:10 -05:00 committed by GitHub
commit f347d664ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 8 deletions

View File

@ -293,6 +293,9 @@
};
onMount(() => {
const chatInput = document.getElementById('chat-textarea');
window.setTimeout(() => chatInput?.focus(), 0);
const dropZone = document.querySelector('body');
const onDragOver = (e) => {

View File

@ -102,17 +102,16 @@
: 'invisible'}"
>
<div class="px-2 flex justify-center space-x-2">
<button
<a
id="sidebar-new-chat-button"
class="flex-grow flex justify-between rounded-xl px-3.5 py-2 hover:bg-gray-900 transition"
href="/"
on:click={async () => {
goto('/');
await goto('/');
const newChatButton = document.getElementById('new-chat-button');
if (newChatButton) {
newChatButton.click();
}
setTimeout(() => {
newChatButton?.click();
}, 0);
}}
>
<div class="flex self-center">
@ -142,7 +141,7 @@
/>
</svg>
</div>
</button>
</a>
</div>
{#if $user?.role === 'admin'}

View File

@ -134,6 +134,9 @@
settings.set({
..._settings
});
const chatInput = document.getElementById('chat-textarea');
setTimeout(() => chatInput?.focus(), 0);
};
const scrollToBottom = () => {

View File

@ -99,6 +99,9 @@
if (await loadChat()) {
await tick();
loaded = true;
const chatInput = document.getElementById('chat-textarea');
chatInput?.focus();
} else {
await goto('/');
}