(core) Fixing bug on a fresh Choice and ChoiceList column

Summary: Adding a new element to a new Choice or ChoiceList column resulted in javascript error

Test Plan: Browser tests

Reviewers: georgegevoian, dsagal

Reviewed By: georgegevoian, dsagal

Subscribers: dsagal

Differential Revision: https://phab.getgrist.com/D2932
This commit is contained in:
Jarosław Sadziński 2021-07-21 12:59:45 +02:00
parent f5981606e1
commit 9cc034f606
2 changed files with 2 additions and 2 deletions

View File

@ -80,7 +80,7 @@ ChoiceEditor.prototype.prepForSave = async function() {
const selectedItem = this.autocomplete && this.autocomplete.getSelectedItem();
if (selectedItem && selectedItem.isNew) {
const choices = this.options.field.widgetOptionsJson.prop('choices');
await choices.saveOnly([...choices.peek(), selectedItem.label]);
await choices.saveOnly([...(choices.peek() || []), selectedItem.label]);
}
}

View File

@ -157,7 +157,7 @@ export class ChoiceListEditor extends NewBaseEditor {
const newChoices = tokens.filter(t => t.isNew).map(t => t.label);
if (newChoices.length > 0) {
const choices = this.options.field.widgetOptionsJson.prop('choices');
await choices.saveOnly([...choices.peek(), ...new Set(newChoices)]);
await choices.saveOnly([...(choices.peek() || []), ...new Set(newChoices)]);
}
}