commit 194343cb0f8dc21f262b901797f628df2b042cb6
parent 1b1df60725e9b00e3cd0351b4285764c7993c3de
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 4 Feb 2013 03:40:57 -0500
Don't update item when leaving an empty field
It looks like this has been happening for at least all of 3.0, including
when tabbing between empty fields.
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -770,7 +770,11 @@ Zotero.Item.prototype.setField = function(field, value, loadIn) {
return true;
}
- if (!Zotero.ItemFields.isValidForType(fieldID, this.itemTypeID)) {
+ if (value === "") {
+ value = false;
+ }
+
+ if (value !== false && !Zotero.ItemFields.isValidForType(fieldID, this.itemTypeID)) {
var msg = "'" + field + "' is not a valid field for type " + this.itemTypeID;
if (loadIn) {
@@ -806,7 +810,9 @@ Zotero.Item.prototype.setField = function(field, value, loadIn) {
}
// If existing value, make sure it's actually changing
- if ((this._itemData[fieldID] + "") === (value + "")) {
+ if ((typeof this._itemData[fieldID] == 'undefined' && value === false)
+ || (typeof this._itemData[fieldID] != 'undefined'
+ && this._itemData[fieldID] === value)) {
return false;
}