From fdb9e20076f37bf365c78098b8dd69610f3b4e41 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 4 Jan 2018 19:10:41 -0500 Subject: [PATCH] Clear parentKey change marker after save Fixes #1325, Field editor closes during auto-sync of newly created parent item --- chrome/content/zotero/xpcom/data/item.js | 5 +++++ test/tests/itemTest.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 15420beffe..266c012776 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -1623,6 +1623,11 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) { yield Zotero.DB.queryAsync(sql, [parentItemID, this.id]); } + // There's no reload for parentKey, so clear it here + if (this._changed.parentKey) { + this._clearChanged('parentKey'); + } + // Note if ((isNew && this.isNote()) || this._changed.note) { if (!isNew) { diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js index 918947978f..deef846cb6 100644 --- a/test/tests/itemTest.js +++ b/test/tests/itemTest.js @@ -438,6 +438,18 @@ describe("Zotero.Item", function () { assert.isFalse(item.hasChanged()); }); + it("should not be marked as changed after a save", async function () { + var item = await createDataObject('item'); + var attachment = new Zotero.Item('attachment'); + attachment.attachmentLinkMode = 'linked_url'; + await attachment.saveTx(); + + attachment.parentKey = item.key; + assert.isTrue(attachment._changed.parentKey); + await attachment.saveTx(); + assert.isUndefined(attachment._changed.parentKey); + }); + it("should move a top-level note under another item", function* () { var noteItem = new Zotero.Item('note'); var id = yield noteItem.saveTx()