From 7c7e16c382941cb3571a5b682cef0d0c217c3c68 Mon Sep 17 00:00:00 2001 From: Jannik Streidl Date: Tue, 27 Feb 2024 13:30:03 +0100 Subject: [PATCH 1/3] added focus selector --- src/lib/components/chat/MessageInput.svelte | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 67bb3d88a..e6ca374d1 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -293,6 +293,9 @@ }; onMount(() => { + const chatInput = document.getElementById('chat-textarea'); + chatInput?.focus(); + const dropZone = document.querySelector('body'); const onDragOver = (e) => { From 1d4d1ddbea8338a289efba8ea45898c401b580a4 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 27 Feb 2024 19:06:32 -0800 Subject: [PATCH 2/3] revert --- src/lib/components/chat/MessageInput.svelte | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index e6ca374d1..67bb3d88a 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -293,9 +293,6 @@ }; onMount(() => { - const chatInput = document.getElementById('chat-textarea'); - chatInput?.focus(); - const dropZone = document.querySelector('body'); const onDragOver = (e) => { From 260a8b8b83705ba3f3133a787dcd0dc6b82e1352 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 27 Feb 2024 19:56:52 -0800 Subject: [PATCH 3/3] feat: chat input focus on new chat --- src/lib/components/chat/MessageInput.svelte | 3 +++ src/lib/components/layout/Sidebar.svelte | 15 +++++++-------- src/routes/(app)/+page.svelte | 3 +++ src/routes/(app)/c/[id]/+page.svelte | 3 +++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 67bb3d88a..f9ff8fc39 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -293,6 +293,9 @@ }; onMount(() => { + const chatInput = document.getElementById('chat-textarea'); + window.setTimeout(() => chatInput?.focus(), 0); + const dropZone = document.querySelector('body'); const onDragOver = (e) => { diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index e0965b080..0cc8b8726 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -101,17 +101,16 @@ : 'invisible'}" >
- +
{#if $user?.role === 'admin'} diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 7d424be47..581db7c09 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -134,6 +134,9 @@ settings.set({ ..._settings }); + + const chatInput = document.getElementById('chat-textarea'); + setTimeout(() => chatInput?.focus(), 0); }; const scrollToBottom = () => { diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 36f342192..515cbeea2 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -99,6 +99,9 @@ if (await loadChat()) { await tick(); loaded = true; + + const chatInput = document.getElementById('chat-textarea'); + chatInput?.focus(); } else { await goto('/'); }