Skip to content

Commit 5666578

Browse files
luoxuanzaoQoder-AI
andauthored
fix(settings): refresh language row labels on live locale switch (#39)
- Obsidian's declarative reconciler re-renders every settings row except the one whose control triggered the change, so the language row kept the previous locale's name/desc after a live switch; patch its leaf text nodes directly after update() - Ignore the .verify-shots/ scratch dir Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
1 parent e53e6fa commit 5666578

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ coverage/
4646

4747
# Temporary screenshots from automated UI verification
4848
/.cu_crop_*.png
49+
/.verify-shots/

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ version with its date and start a fresh empty `[Unreleased]` above it.
5555
mentions just like notes (chipified, no attachment preview); mixed
5656
drags combine note, folder, and image mentions, and only truly
5757
unsupported file types are reported as ignored.
58+
- The settings language row now updates its own label and description
59+
immediately when the display language is changed, instead of keeping
60+
the previous language's text until the settings tab is reopened.
5861

5962
## [1.0.5] - 2026-08-18
6063

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,11 @@ export class QoderianSettingTab extends PluginSettingTab {
438438
await this.plugin.saveSettings();
439439

440440
if (key === 'locale') {
441+
const previousName = t('settings.language.name');
442+
const previousDesc = t('settings.language.desc');
441443
setLocale(this.plugin.settings.locale as Locale);
442444
this.update();
445+
this.refreshLocalizedLanguageRow(previousName, previousDesc);
443446
this.refreshViewChrome();
444447
} else if (key === 'maxTabs') {
445448
for (const view of this.plugin.getAllViews()) {
@@ -460,6 +463,26 @@ export class QoderianSettingTab extends PluginSettingTab {
460463
}
461464
}
462465

466+
/**
467+
* Obsidian's declarative reconciler refreshes every row except the one
468+
* whose control triggered the change, so after a live language switch the
469+
* language row would keep the previous locale's labels until the tab is
470+
* reopened. Patch its leaf text nodes directly; any later full render
471+
* produces the same strings, so this cannot conflict.
472+
*/
473+
private refreshLocalizedLanguageRow(previousName: string, previousDesc: string): void {
474+
const newName = t('settings.language.name');
475+
const newDesc = t('settings.language.desc');
476+
for (const el of Array.from(this.containerEl.querySelectorAll('*'))) {
477+
if (el.children.length !== 0) continue;
478+
if (el.textContent === previousName) {
479+
el.setText(newName);
480+
} else if (el.textContent === previousDesc) {
481+
el.setText(newDesc);
482+
}
483+
}
484+
}
485+
463486
/**
464487
* The declarative renderer reconciles `group.listEl` synchronously after
465488
* every `render` callback returns, removing children it does not own.

‎tests/__mocks__/obsidian.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class PluginSettingTab {
2424
empty: jest.fn(),
2525
createEl: jest.fn().mockReturnValue({ createEl: jest.fn(), createDiv: jest.fn() }),
2626
createDiv: jest.fn().mockReturnValue({ createEl: jest.fn(), createDiv: jest.fn() }),
27+
querySelectorAll: jest.fn().mockReturnValue([]),
2728
};
2829

2930
constructor(app: any, plugin: any) {

0 commit comments

Comments
 (0)