Skip to content

Build your personal knowledge base with Trilium Notes

fix(share): stop the restored tree sections' chevrons from rotating on load

Elian Doran1d317810cb91
diff --git a/packages/share-theme/src/page/navigation.css b/packages/share-theme/src/page/navigation.css
index 0b064e33bd..4fb8c57419 100644
--- a/packages/share-theme/src/page/navigation.css
+++ b/packages/share-theme/src/page/navigation.css
@@ -167,6 +167,10 @@
font-size: 24px;
}
+.tree-restoring .collapse-button > * {
+ transition: none;
+}
+
@media (prefers-reduced-motion: reduce) {
#menu li > ul,
#menu :is(.tree-item-row, li > a),
diff --git a/packages/share-theme/src/page/navigation.ts b/packages/share-theme/src/page/navigation.ts
index b26787b917..0a18bcfcf9 100644
--- a/packages/share-theme/src/page/navigation.ts
+++ b/packages/share-theme/src/page/navigation.ts
@@ -101,6 +101,7 @@ export function setupTreeState() {
/** Expands the entries of the notes in `noteIds`, every clone of each, without animating. */
function expandItems(pane: HTMLElement, noteIds: string[]) {
const ids = new Set(noteIds);
+ pane.classList.add("tree-restoring");
for (const item of pane.querySelectorAll<HTMLElement>("#menu li.submenu-item[data-note-id]")) {
if (!item.dataset.noteId || !ids.has(item.dataset.noteId)) {
continue;
@@ -108,6 +109,9 @@ function expandItems(pane: HTMLElement, noteIds: string[]) {
item.classList.add("expanded");
item.querySelector(":scope > * > .collapse-button")?.setAttribute("aria-expanded", "true");
}
+ // Applies the expanded styles while transitions are off, so the chevrons do not rotate.
+ void pane.offsetHeight;
+ pane.classList.remove("tree-restoring");
}
function readTreeState(): TreeState | null {