mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
fix: prevent auto-focus on mobile when opening diff viewer
Refactored focusInput to accept onMobile parameter to conditionally focus input based on platform, preventing annoying automatic keyboard popup on mobile devices when diff viewer opens/closes.
This commit is contained in:
parent
3e43d9f558
commit
c59bfeb06c
2 changed files with 11 additions and 7 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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<VaultkeeperAIPlugin>(Services.VaultkeeperAIPlugin);
|
||||
const settingsService: SettingsService = Resolve<SettingsService>(Services.SettingsService);
|
||||
|
|
|
|||
Loading…
Reference in a new issue