diff --git a/Components/ChatInput.svelte b/Components/ChatInput.svelte index 21f0a2a..8138ee7 100644 --- a/Components/ChatInput.svelte +++ b/Components/ChatInput.svelte @@ -40,18 +40,21 @@ let diffOpen: boolean = false; - const diffOpenedRef: EventRef = eventService.on(Event.DiffOpened, () => { diffOpen = true; if (!Platform.isMobile){ focusInput(); } }); - const diffClosedRef: EventRef = eventService.on(Event.DiffClosed, () => { diffOpen = false; if (!Platform.isMobile){ focusInput(); } }); + const diffOpenedRef: EventRef = eventService.on(Event.DiffOpened, () => { diffOpen = true; focusInput(); }); + const diffClosedRef: EventRef = eventService.on(Event.DiffClosed, () => { diffOpen = false; focusInput(); }); onDestroy(() => { eventService.offref(diffOpenedRef); eventService.offref(diffClosedRef); }); - export function focusInput() { - tick().then(() => { - textareaElement?.focus(); - }); + export function focusInput(onMobile: boolean = false) { + // don't focus on mobile, it's annoying + if (onMobile || !Platform.isMobile) { + tick().then(() => { + textareaElement?.focus(); + }); + } } $: if (userInstructionButton) { @@ -189,7 +192,7 @@ } e?.preventDefault(); - focusInput(); + focusInput(true); } function handleInput() { diff --git a/Components/ChatWindow.svelte b/Components/ChatWindow.svelte index 1d58739..f1f7f69 100644 --- a/Components/ChatWindow.svelte +++ b/Components/ChatWindow.svelte @@ -15,6 +15,7 @@ import type { SettingsService } from "Services/SettingsService"; import { Copy } from "Enums/Copy"; import { AbortService } from "Services/AbortService"; + import { Platform } from "obsidian"; const plugin: VaultkeeperAIPlugin = Resolve(Services.VaultkeeperAIPlugin); const settingsService: SettingsService = Resolve(Services.SettingsService);