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 67bb3d88..e6ca374d 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 e6ca374d..67bb3d88 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 67bb3d88..f9ff8fc3 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 e0965b08..0cc8b872 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 7d424be4..581db7c0 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 36f34219..515cbeea 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('/'); }