From 2e66174c4a1fa847557f9420731d4eab38d1c5f8 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 13 May 2022 08:26:30 +0200 Subject: [PATCH] Setting focus for questions --- src/commands/Article.ts | 3 ++- src/commands/Content.ts | 3 ++- src/commands/Folders.ts | 3 ++- src/commands/Settings.ts | 24 ++++++++++++++++++------ src/commands/Template.ts | 7 +++++-- src/commands/Wysiwyg.ts | 8 ++++---- src/helpers/Questions.ts | 8 +++++--- 7 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/commands/Article.ts b/src/commands/Article.ts index 90f41f24..c1d825a4 100644 --- a/src/commands/Article.ts +++ b/src/commands/Article.ts @@ -69,7 +69,8 @@ export class Article { const selectedOptions = await vscode.window.showQuickPick(options, { placeHolder: `Select your ${type === TaxonomyType.Tag ? "tags" : "categories"} to insert`, - canPickMany: true + canPickMany: true, + ignoreFocusOut: true }); if (selectedOptions) { diff --git a/src/commands/Content.ts b/src/commands/Content.ts index 6f8c514d..b0f84751 100644 --- a/src/commands/Content.ts +++ b/src/commands/Content.ts @@ -15,7 +15,8 @@ export class Content { const selectedOption = await window.showQuickPick(options, { placeHolder: `Select how you want to create your new content`, - canPickMany: false + canPickMany: false, + ignoreFocusOut: true }); if (selectedOption) { diff --git a/src/commands/Folders.ts b/src/commands/Folders.ts index c006e897..bb5b1cf0 100644 --- a/src/commands/Folders.ts +++ b/src/commands/Folders.ts @@ -118,7 +118,8 @@ export class Folders { folderName = await window.showInputBox({ prompt: `Which name would you like to specify for this folder?`, placeHolder: `Folder name`, - value: basename(folder.fsPath) + value: basename(folder.fsPath), + ignoreFocusOut: true }); } diff --git a/src/commands/Settings.ts b/src/commands/Settings.ts index 5f7b9538..165986fe 100644 --- a/src/commands/Settings.ts +++ b/src/commands/Settings.ts @@ -17,7 +17,8 @@ export class Settings { public static async create(type: TaxonomyType) { const newOption = await vscode.window.showInputBox({ prompt: `Insert the value of the ${type === TaxonomyType.Tag ? "tag" : "category"} that you want to add to your configuration.`, - placeHolder: `Name of the ${type === TaxonomyType.Tag ? "tag" : "category"}` + placeHolder: `Name of the ${type === TaxonomyType.Tag ? "tag" : "category"}`, + ignoreFocusOut: true }); if (newOption) { @@ -36,7 +37,11 @@ export class Settings { await SettingsHelper.updateTaxonomy(type, options); // Ask if the new term needs to be added to the page - const addToPage = await vscode.window.showQuickPick(["yes", "no"], { canPickMany: false, placeHolder: `Do you want to add the new ${type === TaxonomyType.Tag ? "tag" : "category"} to the page?` }); + const addToPage = await vscode.window.showQuickPick(["yes", "no"], { + canPickMany: false, + placeHolder: `Do you want to add the new ${type === TaxonomyType.Tag ? "tag" : "category"} to the page?`, + ignoreFocusOut: true + }); if (addToPage && addToPage === "yes") { const editor = vscode.window.activeTextEditor; @@ -149,7 +154,8 @@ export class Settings { "Category" ], { placeHolder: `What do you want to remap?`, - canPickMany: false + canPickMany: false, + ignoreFocusOut: true }); if (!taxType) { return; @@ -165,7 +171,8 @@ export class Settings { const selectedOption = await vscode.window.showQuickPick(options, { placeHolder: `Select your ${type === TaxonomyType.Tag ? "tags" : "categories"} to insert`, - canPickMany: false + canPickMany: false, + ignoreFocusOut: true }); if (!selectedOption) { @@ -174,11 +181,16 @@ export class Settings { const newOptionValue = await vscode.window.showInputBox({ prompt: `Specify the value of the ${type === TaxonomyType.Tag ? "tag" : "category"} with which you want to remap "${selectedOption}". Leave the input if you want to remove the ${type === TaxonomyType.Tag ? "tag" : "category"} from all articles.`, - placeHolder: `Name of the ${type === TaxonomyType.Tag ? "tag" : "category"}` + placeHolder: `Name of the ${type === TaxonomyType.Tag ? "tag" : "category"}`, + ignoreFocusOut: true }); if (!newOptionValue) { - const deleteAnswer = await vscode.window.showQuickPick(["yes", "no"], { canPickMany: false, placeHolder: `Delete ${selectedOption} ${type === TaxonomyType.Tag ? "tag" : "category"}?` }); + const deleteAnswer = await vscode.window.showQuickPick(["yes", "no"], { + canPickMany: false, + placeHolder: `Delete ${selectedOption} ${type === TaxonomyType.Tag ? "tag" : "category"}?`, + ignoreFocusOut: true + }); if (deleteAnswer === "no") { return; } diff --git a/src/commands/Template.ts b/src/commands/Template.ts index 71122701..ab95ab79 100644 --- a/src/commands/Template.ts +++ b/src/commands/Template.ts @@ -64,7 +64,8 @@ export class Template { const titleValue = await vscode.window.showInputBox({ prompt: `What name would you like to give your template?`, - placeHolder: `article` + placeHolder: `article`, + ignoreFocusOut: true }); if (!titleValue) { @@ -77,6 +78,7 @@ export class Template { { canPickMany: false, placeHolder: `Do you want to keep the contents for the template?`, + ignoreFocusOut: true } ); @@ -122,7 +124,8 @@ export class Template { } const selectedTemplate = await vscode.window.showQuickPick(templates.map(t => path.basename(t.fsPath)), { - placeHolder: `Select the content template to use` + placeHolder: `Select the content template to use`, + ignoreFocusOut: true }); if (!selectedTemplate) { Notifications.warning(`No template selected.`); diff --git a/src/commands/Wysiwyg.ts b/src/commands/Wysiwyg.ts index 657335d2..a20de1cd 100644 --- a/src/commands/Wysiwyg.ts +++ b/src/commands/Wysiwyg.ts @@ -59,8 +59,8 @@ export class Wysiwyg { const option = await window.showQuickPick([ ...qpItems ], { placeHolder: "Which type of markup would you like to insert?", - canPickMany: false, - ignoreFocusOut: false, + canPickMany: false, + ignoreFocusOut: true }); if (option) { @@ -161,8 +161,8 @@ export class Wysiwyg { "Heading 6" ], { canPickMany: false, - placeHolder: "Which heading level do you want to insert?", - ignoreFocusOut: false + placeHolder: "Which heading level do you want to insert?", + ignoreFocusOut: true }); if (headingLvl) { diff --git a/src/helpers/Questions.ts b/src/helpers/Questions.ts index 2252fd8a..a7283670 100644 --- a/src/helpers/Questions.ts +++ b/src/helpers/Questions.ts @@ -11,7 +11,7 @@ export class Questions { * @returns */ public static async yesOrNo(placeholder: string) { - const answer = await window.showQuickPick(["yes", "no"], { canPickMany: false, placeHolder: placeholder, ignoreFocusOut: false }); + const answer = await window.showQuickPick(["yes", "no"], { canPickMany: false, placeHolder: placeholder, ignoreFocusOut: true }); return answer === "yes"; } @@ -23,7 +23,8 @@ export class Questions { public static async ContentTitle(showWarning: boolean = true): Promise { const title = await window.showInputBox({ prompt: `What would you like to use as a title for the content to create?`, - placeHolder: `Content title` + placeHolder: `Content title`, + ignoreFocusOut: true }); if (!title && showWarning) { @@ -82,7 +83,8 @@ export class Questions { const selectedOption = await window.showQuickPick(options, { placeHolder: `Select the content type to create your new content`, - canPickMany: false + canPickMany: false, + ignoreFocusOut: true }); if (!selectedOption && showWarning) {