commit c4fde7ebbf3acd645e3171d87aaa3dba39ce5230
parent 5fcac10db9e35c03bf4f78cf7b4dc15535a81435
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 27 Dec 2017 16:49:07 -0500
Fix undo in notes to not restore changes from another note
Fixes #1398
Diffstat:
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js
@@ -230,15 +230,16 @@ var ZoteroItemPane = new function() {
}
var noteEditor = document.getElementById('zotero-note-editor');
- noteEditor.mode = editable ? 'edit' : 'view';
-
- noteEditor.parent = null;
- noteEditor.item = item;
// If loading new or different note, disable undo while we repopulate the text field
// so Undo doesn't end up clearing the field. This also ensures that Undo doesn't
// undo content from another note into the current one.
var clearUndo = noteEditor.item ? noteEditor.item.id != item.id : false;
+
+ noteEditor.mode = editable ? 'edit' : 'view';
+ noteEditor.parent = null;
+ noteEditor.item = item;
+
if (clearUndo) {
noteEditor.clearUndo();
}
diff --git a/chrome/content/zotero/note.js b/chrome/content/zotero/note.js
@@ -44,13 +44,13 @@ async function onLoad() {
if (itemID) {
var ref = await Zotero.Items.getAsync(itemID);
- var clearUndo = noteEditor.item ? noteEditor.item.id != ref.id : false;
-
- noteEditor.item = ref;
-
// If loading new or different note, disable undo while we repopulate the text field
// so Undo doesn't end up clearing the field. This also ensures that Undo doesn't
// undo content from another note into the current one.
+ let clearUndo = noteEditor.item ? noteEditor.item.id != itemID : false;
+
+ noteEditor.item = ref;
+
if (clearUndo) {
noteEditor.clearUndo();
}