Link empty-state message to plugin settings (#38)

* Link "plugin settings" text to open settings tab in empty-state message

When no properties are configured, the modal now shows "plugin settings"
as a clickable link that closes the modal and navigates directly to the
plugin's settings tab.

* Guard undocumented settings API with feature detection

Check that setting.open and setting.openTabById are functions before
calling them. Falls back to a Notice with manual navigation instructions
if the internal API is absent.

* Add focus-visible indicator for links in the modal
This commit is contained in:
Gary Ritchie 2026-04-04 12:31:42 -06:00 committed by GitHub
parent 95f45ceb31
commit 0e8d99c9ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 1 deletions

View file

@ -182,7 +182,25 @@ export class BulkEditModal extends Modal {
const editableProperties = settings.properties.filter(p => p.name !== settings.selectionProperty);
if (editableProperties.length === 0) {
contentEl.createEl("p", {text: "No properties configured. Add properties in the plugin settings."});
const p = contentEl.createEl("p");
p.appendText("No properties configured. Add properties in the ");
// eslint-disable-next-line obsidianmd/ui/sentence-case -- mid-sentence text
const link = p.createEl("a", {text: "plugin settings", href: "#"});
link.addEventListener("click", (e) => {
e.preventDefault();
this.close();
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call -- undocumented Obsidian API */
const setting = (this.app as any).setting;
if (typeof setting?.open === "function" && typeof setting?.openTabById === "function") {
setting.open();
setting.openTabById(this.plugin.manifest.id);
} else {
// eslint-disable-next-line obsidianmd/ui/sentence-case -- navigation path
new Notice("Open Settings → Community plugins → Bulk Properties to configure properties.");
}
/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */
});
p.appendText(".");
return;
}

View file

@ -12,6 +12,12 @@
font-size: var(--font-ui-medium);
}
.bulk-properties-modal a:focus-visible {
outline: 2px solid var(--background-modifier-border-focus);
outline-offset: 2px;
border-radius: var(--radius-s);
}
.bulk-properties-file-list {
max-height: 200px;
overflow-y: auto;