Fix undo in notes to not restore changes from another note

Fixes #1398
This commit is contained in:
Dan Stillman 2017-12-27 16:49:07 -05:00
parent 5fcac10db9
commit c4fde7ebbf
2 changed files with 9 additions and 8 deletions

View file

@ -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();
}

View file

@ -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();
}