From c4fde7ebbf3acd645e3171d87aaa3dba39ce5230 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 27 Dec 2017 16:49:07 -0500 Subject: [PATCH] Fix undo in notes to not restore changes from another note Fixes #1398 --- chrome/content/zotero/itemPane.js | 9 +++++---- chrome/content/zotero/note.js | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js index 789755a93..d2a62b1ef 100644 --- 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 index 25d7458f5..2240e01b5 100644 --- 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(); }