fix pin disappearing permanently

This commit is contained in:
2025-09-27 17:21:03 -05:00
parent 30bd6dc740
commit 2fb490f0d1

13
main.ts
View File

@@ -77,12 +77,6 @@ export default class TabPinButtonPlugin extends Plugin {
if (typeof leaf.setPinned === "function") leaf.setPinned(!pinned);
else this.toggleViaViewState(leaf as WorkspaceLeaf, !pinned);
this.syncButtonForHeader(header);
// hide if pinned
if (this.isHeaderPinned(header)) {
btn.style.display = "none";
} else {
btn.style.display = "";
}
});
btn.addEventListener("keydown", (e: KeyboardEvent) => {
@@ -105,6 +99,13 @@ export default class TabPinButtonPlugin extends Plugin {
btn.classList.toggle(PINNED_CLASS, isPinned);
btn.setAttribute("aria-pressed", isPinned ? "true" : "false");
btn.title = isPinned ? "Unpin tab" : "Pin tab";
// hide if pinned
if (this.isHeaderPinned(header)) {
btn.style.display = "none";
} else {
btn.style.display = "";
}
}
private isHeaderPinned(header: HTMLElement): boolean {