Skip to content

Build your personal knowledge base with Trilium Notes

render note type dropdown lazily

zadam02ab59c9e075
diff --git a/src/public/javascripts/services/note_type.js b/src/public/javascripts/services/note_type.js
index 74492d894f..3d0b9b59dc 100644
--- a/src/public/javascripts/services/note_type.js
+++ b/src/public/javascripts/services/note_type.js
@@ -60,6 +60,8 @@ class NoteTypeContext {
constructor(ctx) {
this.ctx = ctx;
+ ctx.$tabContent.find('.note-type').on('show.bs.dropdown', () => this.renderDropdown());
+
this.$noteTypeDropdown = ctx.$tabContent.find(".note-type-dropdown");
this.$noteTypeButton = ctx.$tabContent.find(".note-type-button");
this.$noteTypeDesc = ctx.$tabContent.find(".note-type-desc");
@@ -71,9 +73,11 @@ class NoteTypeContext {
this.$noteTypeButton.prop("disabled",
() => ["file", "image", "search"].includes(this.ctx.note.type));
- this.$noteTypeDropdown.empty();
-
this.$noteTypeDesc.text(this.findTypeTitle(this.ctx.note.type));
+ }
+
+ renderDropdown() {
+ this.$noteTypeDropdown.empty();
for (const noteType of NOTE_TYPES.filter(nt => nt.selectable)) {
const $typeLink = $('<a class="dropdown-item">')
diff --git a/src/views/title.ejs b/src/views/title.ejs
index 1d4ead5608..bf3e3331e1 100644
--- a/src/views/title.ejs
+++ b/src/views/title.ejs
@@ -37,7 +37,7 @@
&nbsp; &nbsp;
- <div class="note-type-wrapper" style="display: flex;">
+ <div style="display: flex;">
<div class="dropdown note-type">
<button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle note-type-button">
Type: <span class="note-type-desc"></span>