diff --git a/main.js b/main.js index 584fbfbc..68abaaf6 100644 --- a/main.js +++ b/main.js @@ -37765,8 +37765,9 @@ function addDataviewSettings(plugin, alternativeHierarchyDetails) { .addDropdown((dd) => { const options = {}; fields.forEach((field) => (options[field] = field)); - dd.addOptions(Object.assign(options, { "": "" })); - dd.onChange(async (field) => { + dd.addOptions(Object.assign(options, { "": "" })) + .setValue(settings.dataviewNoteField) + .onChange(async (field) => { settings.dataviewNoteField = field; await plugin.saveSettings(); await refreshIndex(plugin); @@ -37945,12 +37946,13 @@ function addDendronSettings(plugin, alternativeHierarchyDetails) { new obsidian.Setting(dendronDetails) .setName("Dendron Note Field") .setDesc("Which field should Breadcrumbs use for Dendron notes?") - .addDropdown((cb) => { + .addDropdown((dd) => { + dd.setValue(settings.dendronNoteField); fields.forEach((field) => { - cb.addOption(field, field); + dd.addOption(field, field); }); - cb.setValue(settings.dendronNoteField); - cb.onChange(async (value) => { + dd.setValue(settings.dendronNoteField); + dd.onChange(async (value) => { settings.dendronNoteField = value; await plugin.saveSettings(); }); @@ -38118,11 +38120,11 @@ function addHierarchyNoteSettings(plugin, alternativeHierarchyDetails) { .setDesc(fragWithHTML("By default, hierarchy notes use the first up field in your hierarchies. Choose a different one to use by default. If you don't want to choose a default, select the blank option at the bottom of the list.")) .addDropdown((dd) => { const upFields = getFields(settings.userHiers, "up"); - dd.setValue(settings.HNUpField || upFields[0]); const options = {}; upFields.forEach((field) => (options[field] = field)); - dd.addOptions(options); - dd.onChange(async (field) => { + dd.addOptions(options) + .setValue(settings.HNUpField || upFields[0]) + .onChange(async (field) => { settings.HNUpField = field; await plugin.saveSettings(); await refreshIndex(plugin); @@ -39500,8 +39502,9 @@ function addRegexNoteSettings(plugin, alternativeHierarchyDetails) { .addDropdown((dd) => { const options = {}; getFields(settings.userHiers).forEach((field) => (options[field] = field)); - dd.addOptions(Object.assign(options, { "": "" })); - dd.onChange(async (field) => { + dd.addOptions(Object.assign(options, { "": "" })) + .setValue(settings.regexNoteField) + .onChange(async (field) => { settings.regexNoteField = field; await plugin.saveSettings(); await refreshIndex(plugin); @@ -39592,8 +39595,9 @@ function addTagNoteSettings(plugin, alternativeHierarchyDetails) { .addDropdown((dd) => { const options = {}; getFields(settings.userHiers).forEach((field) => (options[field] = field)); - dd.addOptions(Object.assign(options, { "": "" })); - dd.onChange(async (field) => { + dd.addOptions(Object.assign(options, { "": "" })) + .setValue(settings.tagNoteField) + .onChange(async (field) => { settings.tagNoteField = field; await plugin.saveSettings(); await refreshIndex(plugin); diff --git a/src/Settings/DataviewNoteSettings.ts b/src/Settings/DataviewNoteSettings.ts index 24b38c4b..6155db10 100644 --- a/src/Settings/DataviewNoteSettings.ts +++ b/src/Settings/DataviewNoteSettings.ts @@ -21,13 +21,15 @@ export function addDataviewSettings( ) ) .addDropdown((dd: DropdownComponent) => { + const options = {}; fields.forEach((field) => (options[field] = field)); - dd.addOptions(Object.assign(options, { "": "" })); - dd.onChange(async (field) => { - settings.dataviewNoteField = field; - await plugin.saveSettings(); - await refreshIndex(plugin); - }); + dd.addOptions(Object.assign(options, { "": "" })) + .setValue(settings.dataviewNoteField) + .onChange(async (field) => { + settings.dataviewNoteField = field; + await plugin.saveSettings(); + await refreshIndex(plugin); + }); }); } diff --git a/src/Settings/DendronSettings.ts b/src/Settings/DendronSettings.ts index 5f856936..f0d41bee 100644 --- a/src/Settings/DendronSettings.ts +++ b/src/Settings/DendronSettings.ts @@ -70,13 +70,15 @@ export function addDendronSettings( new Setting(dendronDetails) .setName("Dendron Note Field") .setDesc("Which field should Breadcrumbs use for Dendron notes?") - .addDropdown((cb: DropdownComponent) => { + .addDropdown((dd: DropdownComponent) => { + dd.setValue(settings.dendronNoteField); + fields.forEach((field) => { - cb.addOption(field, field); + dd.addOption(field, field); }); - cb.setValue(settings.dendronNoteField); + dd.setValue(settings.dendronNoteField); - cb.onChange(async (value) => { + dd.onChange(async (value) => { settings.dendronNoteField = value; await plugin.saveSettings(); }); diff --git a/src/Settings/HierarchyNoteSettings.ts b/src/Settings/HierarchyNoteSettings.ts index 20ddf7e7..f9ab3e2c 100644 --- a/src/Settings/HierarchyNoteSettings.ts +++ b/src/Settings/HierarchyNoteSettings.ts @@ -44,17 +44,17 @@ export function addHierarchyNoteSettings( ) .addDropdown((dd: DropdownComponent) => { const upFields = getFields(settings.userHiers, "up"); - dd.setValue(settings.HNUpField || upFields[0]) const options = {}; upFields.forEach( (field) => (options[field] = field) ); - dd.addOptions(options); - dd.onChange(async (field) => { - settings.HNUpField = field; - await plugin.saveSettings(); - await refreshIndex(plugin); - }); + dd.addOptions(options) + .setValue(settings.HNUpField || upFields[0]) + .onChange(async (field) => { + settings.HNUpField = field; + await plugin.saveSettings(); + await refreshIndex(plugin); + }); }); } diff --git a/src/Settings/RegexNoteSettings.ts b/src/Settings/RegexNoteSettings.ts index 8d832a56..f9b5dc88 100644 --- a/src/Settings/RegexNoteSettings.ts +++ b/src/Settings/RegexNoteSettings.ts @@ -26,11 +26,12 @@ export function addRegexNoteSettings( getFields(settings.userHiers).forEach( (field) => (options[field] = field) ); - dd.addOptions(Object.assign(options, { "": "" })); - dd.onChange(async (field) => { - settings.regexNoteField = field; - await plugin.saveSettings(); - await refreshIndex(plugin); - }); + dd.addOptions(Object.assign(options, { "": "" })) + .setValue(settings.regexNoteField) + .onChange(async (field) => { + settings.regexNoteField = field; + await plugin.saveSettings(); + await refreshIndex(plugin); + }); }); } diff --git a/src/Settings/TagNoteSettings.ts b/src/Settings/TagNoteSettings.ts index 6cc86289..395f0aaa 100644 --- a/src/Settings/TagNoteSettings.ts +++ b/src/Settings/TagNoteSettings.ts @@ -19,15 +19,17 @@ export function addTagNoteSettings( ) ) .addDropdown((dd: DropdownComponent) => { + const options = {}; getFields(settings.userHiers).forEach( (field) => (options[field] = field) ); - dd.addOptions(Object.assign(options, { "": "" })); - dd.onChange(async (field) => { - settings.tagNoteField = field; - await plugin.saveSettings(); - await refreshIndex(plugin); - }); + dd.addOptions(Object.assign(options, { "": "" })) + .setValue(settings.tagNoteField) + .onChange(async (field) => { + settings.tagNoteField = field; + await plugin.saveSettings(); + await refreshIndex(plugin); + }); }); }