(core) Fixing DELETE and BACKSPACE keys on ChoiceList and RefList editor.

Summary:
Choice/Reference List editor wasn't clearing itself when it received an empty string. It led
to a bug on the Card widget where pressing those keys resulted in the same behavior as
pressing Enter - it just opened the editor.
Grid view has it's own implementation for those keys, so it wasn't affected.

Test Plan: Added new test.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3908
This commit is contained in:
Jarosław Sadziński
2023-06-01 16:24:15 +02:00
parent dad41b2567
commit c592691e31
5 changed files with 159 additions and 8 deletions

View File

@@ -66,7 +66,7 @@ export class ChoiceListEditor extends NewBaseEditor {
// If starting to edit by typing in a string, ignore previous tokens.
const cellValue = decodeObject(options.cellValue);
const startLabels: unknown[] = options.editValue || !Array.isArray(cellValue) ? [] : cellValue;
const startLabels: unknown[] = options.editValue !== undefined || !Array.isArray(cellValue) ? [] : cellValue;
const startTokens = startLabels.map(label => new ChoiceItem(String(label), !choiceSet.has(String(label))));
this._tokenField = TokenField.ctor<ChoiceItem>().create(this, {

View File

@@ -73,7 +73,7 @@ export class ReferenceListEditor extends NewBaseEditor {
// If starting to edit by typing in a string, ignore previous tokens.
const cellValue = decodeObject(options.cellValue);
const startRowIds: unknown[] = options.editValue || !Array.isArray(cellValue) ? [] : cellValue;
const startRowIds: unknown[] = options.editValue !== undefined || !Array.isArray(cellValue) ? [] : cellValue;
// If referenced table hasn't loaded yet, hold off on initializing tokens.
const needReload = (options.editValue === undefined && !this._utils.tableData.isLoaded);