www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit a8d199967ee9f0ea58130a88eae5b3790e52eda5
parent 8d0dc359b428e16468c5cd0363ab7317cd5331f8
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun,  1 Apr 2018 15:34:44 -0400

Fix crash if item field invalid for new type is open on type change

https://forums.zotero.org/discussion/71200/bug-when-changing-item-type-report-id-607330517

Diffstat:
Mchrome/content/zotero/bindings/itembox.xml | 19++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml @@ -1087,12 +1087,17 @@ <method name="changeTypeTo"> <parameter name="itemTypeID"/> <parameter name="menu"/> - <body> - <![CDATA[ + <body><![CDATA[ + return (async function () { if (itemTypeID == this.item.itemTypeID) { return true; } + if (this.saveOnEdit) { + await this.blurOpenField(); + await this.item.saveTx(); + } + var fieldsToDelete = this.item.getFieldsNotInType(itemTypeID, true); // Special cases handled below @@ -1149,15 +1154,15 @@ if (this.saveOnEdit) { // See note in transformText() - this.blurOpenField().then(() => this.item.saveTx()); + await this.blurOpenField(); + await this.item.saveTx(); } else { this.refresh(); } if (this.eventHandlers['itemtypechange'] && this.eventHandlers['itemtypechange'].length) { - var self = this; - this.eventHandlers['itemtypechange'].forEach(function (f) f.bind(self)()); + this.eventHandlers['itemtypechange'].forEach(f => f.bind(this)()); } return true; @@ -1169,8 +1174,8 @@ } return false; - ]]> - </body> + }.bind(this))(); + ]]></body> </method>