From 99a1ac62c7ec0077650e6c02e27870c31fb9e944 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 9 Jul 2018 14:54:50 +0200 Subject: [PATCH] Fix a couple cases of open item box field changes not being saved When clicking directly from an open field to the creator delete button or a creator type in the creator type menu --- chrome/content/zotero/bindings/itembox.xml | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml index 95df1a5a30..72e7c93f40 100644 --- a/chrome/content/zotero/bindings/itembox.xml +++ b/chrome/content/zotero/bindings/itembox.xml @@ -1402,8 +1402,8 @@ - - - + await this.blurOpenField(); + await this.item.saveTx(); + }.bind(this))(); + ]]> @@ -2368,20 +2369,19 @@ document.getElementById('zotero-creator-move-sep').setAttribute('hidden', hideMoveSep); document.getElementById('zotero-creator-move-up').setAttribute('hidden', hideMoveUp); document.getElementById('zotero-creator-move-down').setAttribute('hidden', hideMoveDown);" - oncommand="var typeBox = document.popupNode.localName == 'hbox' ? document.popupNode : document.popupNode.parentNode; + oncommand="return async function () { + var typeBox = document.popupNode.localName == 'hbox' ? document.popupNode : document.popupNode.parentNode; var index = parseInt(typeBox.getAttribute('fieldname').split('-')[1]); - var itemBox = document.getBindingParent(this); - if (event.explicitOriginalTarget.className == 'zotero-creator-move') { var up = event.explicitOriginalTarget.id == 'zotero-creator-move-up'; - itemBox.moveCreator(index, up); + this.moveCreator(index, up); return; } var typeID = event.explicitOriginalTarget.getAttribute('typeid'); var row = typeBox.parentNode; - var fields = itemBox.getCreatorFields(row); + var fields = this.getCreatorFields(row); fields.creatorTypeID = typeID; typeBox.getElementsByTagName('label')[0].setAttribute( 'value', @@ -2397,13 +2397,14 @@ var changedParams = { creatorTypeID: typeID }; - itemBox._updateAutoCompleteParams(row, changedParams); + this._updateAutoCompleteParams(row, changedParams); - itemBox.modifyCreator(index, fields); - if (itemBox.saveOnEdit) { - itemBox.item.saveTx(); + this.modifyCreator(index, fields); + if (this.saveOnEdit) { + await this.blurOpenField(); + await this.item.saveTx(); } - "/> + }.bind(document.getBindingParent(this))();"/>