From cd72ea524e52290181195ceb01c20bb57da29b6d Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 23 Mar 2023 23:47:28 +0100 Subject: [PATCH] promoted and inherited attributes should be shown grouped based on the owning note, #3761 --- src/public/app/entities/fnote.js | 9 ++++++++- .../ribbon_widgets/inherited_attribute_list.js | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/public/app/entities/fnote.js b/src/public/app/entities/fnote.js index 1f44a97bf..70594d647 100644 --- a/src/public/app/entities/fnote.js +++ b/src/public/app/entities/fnote.js @@ -706,7 +706,14 @@ class FNote { }); // attrs are not resorted if position changes after initial load - promotedAttrs.sort((a, b) => a.position < b.position ? -1 : 1); + promotedAttrs.sort((a, b) => { + if (a.noteId === b.noteId) { + return a.position < b.position ? -1 : 1; + } else { + // inherited promoted attributes should stay grouped: https://github.com/zadam/trilium/issues/3761 + return a.noteId < b.noteId ? -1 : 1; + } + }); return promotedAttrs; } diff --git a/src/public/app/widgets/ribbon_widgets/inherited_attribute_list.js b/src/public/app/widgets/ribbon_widgets/inherited_attribute_list.js index e434c20a6..01031686e 100644 --- a/src/public/app/widgets/ribbon_widgets/inherited_attribute_list.js +++ b/src/public/app/widgets/ribbon_widgets/inherited_attribute_list.js @@ -92,7 +92,18 @@ export default class InheritedAttributesWidget extends NoteContextAwareWidget { } getInheritedAttributes(note) { - return note.getAttributes().filter(attr => attr.noteId !== this.noteId); + const attrs = note.getAttributes().filter(attr => attr.noteId !== this.noteId); + + attrs.sort((a, b) => { + if (a.noteId === b.noteId) { + return a.position < b.position ? -1 : 1; + } else { + // inherited attributes should stay grouped: https://github.com/zadam/trilium/issues/3761 + return a.noteId < b.noteId ? -1 : 1; + } + }); + + return attrs; } entitiesReloadedEvent({loadResults}) {