Skip to content

Commit ce86481

Browse files
luoxuanzaoQoder-AI
andcommitted
fix(settings): render the settings window without the deprecated display()
The header settings window called PluginSettingTab.display(), which is deprecated since Obsidian 1.13.0. Add a mount(container) entry point that shares the existing imperative renderer with the pre-1.13 display() fallback that Obsidian still owns. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
1 parent c559d16 commit ce86481

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎src/features/settings/settings-modal.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export class QoderianSettingsModal extends Modal {
1818
this.titleEl.setText(t('settings.title'));
1919

2020
const settingsTab = new QoderianSettingTab(this.app, this.plugin);
21-
settingsTab.containerEl = this.contentEl;
22-
settingsTab.display();
21+
settingsTab.mount(this.contentEl);
2322
this.settingsTab = settingsTab;
2423
}
2524

‎src/features/settings/settings-tab.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,16 @@ export class QoderianSettingTab extends PluginSettingTab {
502502
}
503503
}
504504

505+
/**
506+
* Imperative renderer for hosts outside Obsidian's settings pane, such as
507+
* the header settings window. Shares the same builders as the pre-1.13
508+
* display() fallback, which Obsidian owns for older versions.
509+
*/
510+
mount(containerEl: HTMLElement): void {
511+
this.containerEl = containerEl;
512+
this.renderLegacySettings();
513+
}
514+
505515
/**
506516
* Imperative entry point for Obsidian versions older than 1.13.0, which
507517
* never consult getSettingDefinitions(). Kept as the documented fallback

‎tests/unit/features/settings/settings-modal.test.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { QoderianSettingsModal } from '@/features/settings/settings-modal';
44

55
let lastModalInstance: any;
66
const mockSettingsTab = {
7-
containerEl: null as any,
8-
display: jest.fn(),
7+
mount: jest.fn(),
98
hide: jest.fn(),
109
};
1110

@@ -50,8 +49,7 @@ jest.mock('@/features/settings/settings-tab', () => ({
5049

5150
describe('QoderianSettingsModal', () => {
5251
beforeEach(() => {
53-
mockSettingsTab.containerEl = null;
54-
mockSettingsTab.display.mockClear();
52+
mockSettingsTab.mount.mockClear();
5553
mockSettingsTab.hide.mockClear();
5654
});
5755

@@ -60,8 +58,7 @@ describe('QoderianSettingsModal', () => {
6058

6159
expect(lastModalInstance.modalEl.addClass).toHaveBeenCalledWith('qoderian-settings-modal');
6260
expect(lastModalInstance.titleEl.setText).toHaveBeenCalledWith('Qoderian Settings');
63-
expect(mockSettingsTab.containerEl).toBe(lastModalInstance.contentEl);
64-
expect(mockSettingsTab.display).toHaveBeenCalledTimes(1);
61+
expect(mockSettingsTab.mount).toHaveBeenCalledWith(lastModalInstance.contentEl);
6562
});
6663

6764
it('detaches the settings tab when the window closes', () => {

0 commit comments

Comments
 (0)