From 508c5f9f9184ab7f26612068b093b172e4a7f2c9 Mon Sep 17 00:00:00 2001 From: Clare Macrae Date: Thu, 10 Oct 2024 21:57:43 +0100 Subject: [PATCH] fix: Restore 'collapsed' state of Status setting sections There has been an un-reported bug for a long time, that the open/closed state of the collapse buttons on the Core Status and Custom Status sections of the Tasks Settings were not restored when the settings were re-opened, either in the same session, or when restarting Obsidian. --- src/Config/SettingsTab.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Config/SettingsTab.ts b/src/Config/SettingsTab.ts index 9ce1106628..5fc02df6d7 100644 --- a/src/Config/SettingsTab.ts +++ b/src/Config/SettingsTab.ts @@ -155,7 +155,9 @@ export class SettingsTab extends PluginSettingTab { const { headingOpened } = getSettings(); settingsJson.forEach((heading) => { - this.addOneSettingsBlock(containerEl, heading, headingOpened); + const initiallyOpen = headingOpened[heading.text] ?? true; + const detailsContainer = this.addOneSettingsBlock(containerEl, heading, headingOpened); + detailsContainer.open = initiallyOpen; }); // --------------------------------------------------------------------------- @@ -379,7 +381,11 @@ export class SettingsTab extends PluginSettingTab { }); } - private addOneSettingsBlock(containerEl: HTMLElement, heading: any, headingOpened: HeadingState) { + private addOneSettingsBlock( + containerEl: HTMLElement, + heading: any, + headingOpened: HeadingState, + ): HTMLDetailsElement { const detailsContainer = containerEl.createEl('details', { cls: 'tasks-nested-settings', attr: { @@ -488,6 +494,8 @@ export class SettingsTab extends PluginSettingTab { } } }); + + return detailsContainer; } private static parseCommaSeparatedFolders(input: string): string[] {