mirror of
https://github.com/zadam/trilium.git
synced 2025-10-30 09:56:36 +01:00
fix #32, could not open attribute dialog if it didn't have any attributes yet
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user