Fix restart error moving away from note that hadn't finished loading

This commit is contained in:
Dan Stillman 2017-08-30 17:22:47 -04:00
parent 000e7f9744
commit 94c4445475
2 changed files with 13 additions and 3 deletions

View File

@ -251,8 +251,14 @@
return; return;
} }
// Update note
var noteField = this._id('noteField'); var noteField = this._id('noteField');
var value = noteField.value;
if (value === null) {
Zotero.debug("Note value not available -- not saving", 2);
return;
}
// Update note
if (this.item) { if (this.item) {
// If note field doesn't match item, abort save and run error handler // If note field doesn't match item, abort save and run error handler
if (noteField.getAttribute('itemID') != this.item.id) { if (noteField.getAttribute('itemID') != this.item.id) {
@ -263,7 +269,7 @@
throw new Error("Note field doesn't match current item"); throw new Error("Note field doesn't match current item");
} }
let changed = this.item.setNote(noteField.value); let changed = this.item.setNote(value);
if (changed && this.saveOnEdit) { if (changed && this.saveOnEdit) {
this.noteField.changed = false; this.noteField.changed = false;
yield this.item.saveTx({ yield this.item.saveTx({
@ -280,7 +286,7 @@
if (this.parentItem) { if (this.parentItem) {
item.libraryID = this.parentItem.libraryID; item.libraryID = this.parentItem.libraryID;
} }
item.setNote(noteField.value); item.setNote(value);
if (this.parentItem) { if (this.parentItem) {
item.parentKey = this.parentItem.key; item.parentKey = this.parentItem.key;
} }

View File

@ -500,6 +500,10 @@
<!-- Sets or returns contents of rich text box --> <!-- Sets or returns contents of rich text box -->
<property name="value"> <property name="value">
<getter><![CDATA[ <getter><![CDATA[
if (!this._editor) {
return null;
}
var output = this._editor.getContent().trim(); var output = this._editor.getContent().trim();
if(this._format == "RTF") { if(this._format == "RTF") {