Skip to content

hideVaultName

Hides every element whose text is exactly the vault’s name.

Keyed on app.vault.getName() rather than on a class of Obsidian’s chrome, deliberately: the varying thing is the DATA, and the row that renders it has moved between Obsidian versions before. Obsidian’s own hide() rather than an inline style.visibility or an injected stylesheet, because those are what obsidianmd/no-static-styles-assignment and obsidianmd/no-forbidden-elements respectively refuse.

Only leaf elements match (childElementCount === 0), so an ancestor whose textContent happens to concatenate to the same string is left alone — on a vault named after the only note in it, hiding the ancestor would blank half the frame.

Idempotent, and meant to be re-applied. hide() leaves the text in place, so a second call finds what the first one hid; and it has to, because a re-render of the sidedock between two captures puts the row back.

Not asserted here. Zero is a legitimate answer — the mobile app renders no vault-switcher row at all — so the count is returned rather than checked. A desktop capture suite that wants to fail loudly when Obsidian relocates the row should assert on it itself.

Import:

import { hideVaultName } from 'obsidian-integration-testing';

Signature:

function hideVaultName(options: HideVaultNameOptions | undefined): Promise<number>

Parameters:

ParameterTypeDescription
optionsHideVaultNameOptions | undefinedTransport and vault overrides.

Returns: Promise<number> — A Promise that resolves to the number of elements hidden.


Links to this page: