Skip to content

Build your personal knowledge base with Trilium Notes

add option to disable note tree auto collapse, fixes #1751

zadame8903e82a162
diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js
index 082ca86ec1..e2cee7c4fe 100644
--- a/src/public/app/widgets/note_tree.js
+++ b/src/public/app/widgets/note_tree.js
@@ -176,6 +176,15 @@ const TPL = `
title="Images which are shown in the parent text note will not be displayed in the tree"></span>
</label>
</div>
+ <div class="form-check">
+ <label class="form-check-label">
+ <input class="form-check-input auto-collapse-note-tree" type="checkbox" value="">
+
+ Automatically collapse notes
+ <span class="bx bx-info-circle"
+ title="Notes will be collapsed after period of inactivity to declutter the tree."></span>
+ </label>
+ </div>
<br/>
@@ -235,6 +244,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
this.$treeSettingsPopup = this.$widget.find('.tree-settings-popup');
this.$hideArchivedNotesCheckbox = this.$treeSettingsPopup.find('.hide-archived-notes');
this.$hideIncludedImages = this.$treeSettingsPopup.find('.hide-included-images');
+ this.$autoCollapseNoteTree = this.$treeSettingsPopup.find('.auto-collapse-note-tree');
this.$treeSettingsButton = this.$widget.find('.tree-settings-button');
this.$treeSettingsButton.on("click", e => {
@@ -245,6 +255,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
this.$hideArchivedNotesCheckbox.prop("checked", this.hideArchivedNotes);
this.$hideIncludedImages.prop("checked", this.hideIncludedImages);
+ this.$autoCollapseNoteTree.prop("checked", this.autoCollapseNoteTree);
let top = this.$treeSettingsButton[0].offsetTop;
let left = this.$treeSettingsButton[0].offsetLeft;
@@ -272,6 +283,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
this.$saveTreeSettingsButton.on('click', async () => {
await this.setHideArchivedNotes(this.$hideArchivedNotesCheckbox.prop("checked"));
await this.setHideIncludedImages(this.$hideIncludedImages.prop("checked"));
+ await this.setAutoCollapseNoteTree(this.$autoCollapseNoteTree.prop("checked"));
this.$treeSettingsPopup.hide();
@@ -327,6 +339,14 @@ export default class NoteTreeWidget extends TabAwareWidget {
await options.save("hideIncludedImages_" + this.treeName, val.toString());
}
+ get autoCollapseNoteTree() {
+ return options.is("autoCollapseNoteTree");
+ }
+
+ async setAutoCollapseNoteTree(val) {
+ await options.save("autoCollapseNoteTree", val.toString());
+ }
+
initFancyTree() {
const treeData = [this.prepareRootNode()];
@@ -961,6 +981,10 @@ export default class NoteTreeWidget extends TabAwareWidget {
}
this.autoCollapseTimeoutId = setTimeout(() => {
+ if (!this.autoCollapseNoteTree) {
+ return;
+ }
+
/*
* We're collapsing notes after period of inactivity to "cleanup" the tree - users rarely
* collapse the notes and the tree becomes unusuably large.
diff --git a/src/routes/api/options.js b/src/routes/api/options.js
index d08581037d..4928adcce2 100644
--- a/src/routes/api/options.js
+++ b/src/routes/api/options.js
@@ -41,7 +41,8 @@ const ALLOWED_OPTIONS = new Set([
'attributeListExpanded',
'promotedAttributesExpanded',
'similarNotesExpanded',
- 'headingStyle'
+ 'headingStyle',
+ 'autoCollapseNoteTree'
]);
function getOptions() {
diff --git a/src/services/options_init.js b/src/services/options_init.js
index 35b2768de0..81ac7b53c5 100644
--- a/src/services/options_init.js
+++ b/src/services/options_init.js
@@ -86,6 +86,7 @@ const defaultOptions = [
{ name: 'similarNotesExpanded', value: 'true', isSynced: true },
{ name: 'debugModeEnabled', value: 'false', isSynced: false },
{ name: 'headingStyle', value: 'markdown', isSynced: true },
+ { name: 'autoCollapseNoteTree', value: 'true', isSynced: true },
];
function initStartupOptions() {