Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix #32, could not open attribute dialog if it didn't have any attributes yet
azivner23a2b58b24c0
diff --git a/src/public/javascripts/dialogs/attributes.js b/src/public/javascripts/dialogs/attributes.jsindex 91ca2c8490..8b6318c10d 100644--- a/src/public/javascripts/dialogs/attributes.js+++ b/src/public/javascripts/dialogs/attributes.js@@ -22,7 +22,8 @@ const attributesDialog = (function() {attributeNames = await server.get('attributes/names');- $(".attribute-name:last").focus();+ // attribute might not be rendered immediatelly so could not focus+ setTimeout(() => $(".attribute-name:last").focus(), 100);};function isValid() {@@ -65,9 +66,9 @@ const attributesDialog = (function() {function addLastEmptyRow() {const attrs = self.attributes();- const last = attrs[attrs.length - 1]();+ const last = attrs.length === 0 ? null : attrs[attrs.length - 1]();- if (last.name.trim() !== "" || last.value !== "") {+ if (!last || last.name.trim() !== "" || last.value !== "") {self.attributes.push(ko.observable({attributeId: '',name: '',@@ -149,8 +150,6 @@ const attributesDialog = (function() {$(this).autocomplete("search", $(this).val());});- $(document).on('blur', '.attribute-name', function (e) { console.log("blur!"); });-$(document).on('focus', '.attribute-value', async function (e) {if (!$(this).hasClass("ui-autocomplete-input")) {const attributeName = $(this).parent().parent().find('.attribute-name').val();diff --git a/src/views/index.ejs b/src/views/index.ejsindex fc04c89c71..12a1ada997 100644--- a/src/views/index.ejs+++ b/src/views/index.ejs@@ -389,7 +389,7 @@<div id="attributes-dialog" title="Note attributes" style="display: none; padding: 20px;"><form data-bind="submit: save"><div style="text-align: center">- <button class="btn-primary btn-large" id="save-attributes-button" type="submit">Save</button>+ <button class="btn btn-large" style="width: 200px;" id="save-attributes-button" type="submit">Save <kbd>enter</kbd></button></div><div style="height: 97%; overflow: auto">