Item box: Fix fieldMode resetting after editor hidden twice

hideEditor() called switchCreatorMode() too early, setting the fieldMode
attribute on the soon-to-be-discarded textbox instead of the label
replacing it. Then, showing the editor a second time would carry over an
empty fieldMode attribute from the label to the new textbox. Hiding that
editor would update the creator in the item to fieldMode = 0 and trigger
a save.

Moving the switchCreatorMode() call does the trick, and the flex
settings changes still work fine when made there.
This commit is contained in:
Abe Jellinek 2022-08-05 17:06:04 -04:00
parent 2048319541
commit 87455d28c3

View file

@ -1932,8 +1932,6 @@
newVal = val;
// Reset creator mode settings here so that flex attribute gets reset
this.switchCreatorMode(row, (otherFields.fieldMode ? 1 : 0), true);
if (Zotero.ItemTypes.getName(this.item.itemTypeID) === "bookSection") {
var creatorTypeLabels = document.getAnonymousNodes(this)[0].getElementsByClassName("creator-type-label");
Zotero.debug(creatorTypeLabels[creatorTypeLabels.length-1] + "");
@ -2018,6 +2016,11 @@
// Disassociate textbox from label
label.setAttribute('control', elem.getAttribute('id'));
if (field == 'creator') {
// Set correct flex settings and fieldMode attribute
this.switchCreatorMode(row, (otherFields.fieldMode ? 1 : 0), true);
}
if (this.saveOnEdit) {
await this.item.saveTx();
}