From 4cbec0b01e3ad37ded8c0aab1f1149c36426ac88 Mon Sep 17 00:00:00 2001 From: Murphy Date: Sun, 9 Jun 2024 14:11:18 +0200 Subject: [PATCH] fix: keyboard not opening on command --- src/settings.ts | 2 +- src/utils/searchModal.ts | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/settings.ts b/src/settings.ts index e7eb829..15f449d 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -160,7 +160,7 @@ export class WikipediaSearchSettingTab extends PluginSettingTab { new Setting(containerEl) .setName("Auto-search note title") - .setDesc("Whether or not to automatically use the active notes title when searching for articles.") + .setDesc("Whether or not to automatically use the active notes title when searching for articles and nothing is selected.") .addToggle((toggle) => toggle.setValue(this.settings.autoSearchNoteTitle).onChange(async (value) => { this.settings.autoSearchNoteTitle = value; diff --git a/src/utils/searchModal.ts b/src/utils/searchModal.ts index aa33096..559e669 100644 --- a/src/utils/searchModal.ts +++ b/src/utils/searchModal.ts @@ -22,18 +22,14 @@ export abstract class SearchModal extends SuggestModal
{ } onOpen(): void { - this.inputEl.value = ""; - if (this.editor) { - const selection = this.editor?.getSelection(); - if (selection != "") { - this.inputEl.value = selection; - } - } + super.onOpen(); if (this.settings.autoSearchNoteTitle) { const fileName = this.app.workspace.getActiveFile()?.basename; - if (fileName && fileName != "") { - this.inputEl.value = fileName; - } + if (fileName && fileName != "") this.inputEl.value = fileName; + } + if (this.editor) { + const selection = this.editor.getSelection(); + if (selection.trim() != "") this.inputEl.value = selection; } //@ts-ignore - private method super.updateSuggestions();