Fix #1038, Notes skip back to beginning if typing during auto-save
Set a unique id on the note editor at initialization and pass it along to item.saveTx(). When notify() is called, if the save was triggered from the current note field, don't do a refresh. This does mean that the note field won't reflect changes (e.g., normalizations) made by the save process until the user clicks away and back, which makes me a little uncomfortable. If we can find specific cases where that occurs (paste?), we can reevaluate this approach.
This commit is contained in:
parent
69dec87aa6
commit
381fe38b89
1 changed files with 11 additions and 1 deletions
|
@ -144,6 +144,7 @@
|
||||||
|
|
||||||
<constructor>
|
<constructor>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
this._instanceID = Zotero.Utilities.randomString();
|
||||||
this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'noteeditor');
|
this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'noteeditor');
|
||||||
]]>
|
]]>
|
||||||
</constructor>
|
</constructor>
|
||||||
|
@ -158,6 +159,7 @@
|
||||||
<parameter name="event"/>
|
<parameter name="event"/>
|
||||||
<parameter name="type"/>
|
<parameter name="type"/>
|
||||||
<parameter name="ids"/>
|
<parameter name="ids"/>
|
||||||
|
<parameter name="extraData"/>
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
if (event != 'modify' || !this.item || !this.item.id) return;
|
if (event != 'modify' || !this.item || !this.item.id) return;
|
||||||
for (let i = 0; i < ids.length; i++) {
|
for (let i = 0; i < ids.length; i++) {
|
||||||
|
@ -165,6 +167,10 @@
|
||||||
if (id != this.item.id) {
|
if (id != this.item.id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (extraData && extraData[id] && extraData[id].noteEditorID == this._instanceID) {
|
||||||
|
//Zotero.debug("Skipping notification from current note field");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
this.refresh();
|
this.refresh();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +249,11 @@
|
||||||
if (this.item) {
|
if (this.item) {
|
||||||
let changed = this.item.setNote(noteField.value);
|
let changed = this.item.setNote(noteField.value);
|
||||||
if (changed && this.saveOnEdit) {
|
if (changed && this.saveOnEdit) {
|
||||||
yield this.item.saveTx();
|
yield this.item.saveTx({
|
||||||
|
notifierData: {
|
||||||
|
noteEditorID: this._instanceID
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue