From ae9c54b76d4eb033f785f1fde9f2a5691ef230ad Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 5 Mar 2019 19:15:50 -0500 Subject: [PATCH] Fix "Move to Top" logic for creators --- chrome/content/zotero/bindings/itembox.xml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml index 769d047a4e..4dbc9330b3 100644 --- a/chrome/content/zotero/bindings/itembox.xml +++ b/chrome/content/zotero/bindings/itembox.xml @@ -2196,10 +2196,21 @@ newIndex = index + 1; break; } - var a = this.item.getCreator(index); - var b = this.item.getCreator(newIndex); - this.item.setCreator(newIndex, a); - this.item.setCreator(index, b); + let creator = this.item.getCreator(index); + // When moving to top, increment index of all other creators + if (dir == 'top') { + let otherCreators = this.item.getCreators(); + this.item.setCreator(newIndex, creator); + for (let i = 0; i < index; i++) { + this.item.setCreator(i + 1, otherCreators[i]); + } + } + // When moving up or down, swap places with next creator + else { + let otherCreator = this.item.getCreator(newIndex); + this.item.setCreator(newIndex, creator); + this.item.setCreator(index, otherCreator); + } if (this.saveOnEdit) { // See note in transformText() yield this.blurOpenField();