Lib.openSettingsTab
Lib › openSettingsTab
Type: (this: void, params: OpenSettingsTabParams) => Promise<string[]>
Opens Obsidian's settings modal on a given tab, and does not return until that tab has actually rendered.**This exists because
app.setting.open() on its own does not work from a test.** app.setting.containerEl is built at startup but is never in the document, and open() does not attach it — so the modal builds into a detached tree, open() returns without throwing, and a screenshot taken afterwards shows the untouched document. That is what made the settings tab look impossible to capture, and got recorded as such in two plugins.The fix is one step, and its **order is load-bearing**: the container is appended to
document.body **before** open(). Attaching afterwards is too late — whatever the modal drew on open has already gone into the detached container, so it ends up on screen showing the wrong thing. That failure looks like success until the captured frame is examined, which is the trap this helper exists to remove.Re-attaching is idempotent, so a tab closed with
app.setting.close() can simply be re-opened.