(core) Accept values entered into Reference columns showing RowIDs without waiting.

Summary:
- Normally Reference columns can only be used for data entry once the target
  table has loaded. When it shows RowID, we shouldn't need to wait.
- Also, fix pasting values between cells of a RowID-showing column.

Test Plan: Added a test for entering data before data has loaded.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2902
This commit is contained in:
Dmitry S 2021-07-08 12:18:46 -04:00
parent d0905b6224
commit 11c944d794
2 changed files with 7 additions and 2 deletions

View File

@ -107,7 +107,7 @@ function makePasteHtml(tableData, selection, includeColHeaders) {
let rawValue = col.rawGetter(rowId);
let fmtValue = col.fmtGetter(rowId);
let dataOptions = {};
if (rawValue != fmtValue) {
if (rawValue !== fmtValue) {
dataOptions['data-grist-raw-value'] = JSON.stringify(rawValue);
}
return dom('td', dataOptions, fmtValue);

View File

@ -128,7 +128,12 @@ export class ReferenceEditor extends NTextEditor {
if (matches.length > 0) {
return matches[0].value;
} else {
return this.textInput.value;
const value = this.textInput.value;
if (this._visibleCol === 'id') {
// If the value is a valid number (non-NaN), save as a numeric rowId; else as text.
return +value || value;
}
return value;
}
}