fix(grid): replace matches in truncated large values
This commit is contained in:
6 files changed
+157
-24
No files matched your search
@@ -213,6 +213,24 @@ describe("useDataGridEditor searched replacements", () => {
|
||||
expect(mocks.executeBatch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("stages a resolved large-value replacement while the source row still contains its preview", () => {
|
||||
const editor = createEditor(undefined, true, undefined, undefined, [["prefix hit…"]]);
|
||||
editor.newRows.value = [];
|
||||
|
||||
expect(
|
||||
editor.stageCellReplacements([
|
||||
{
|
||||
rowId: 0,
|
||||
col: 0,
|
||||
sourceValue: "prefix hit…",
|
||||
previousValue: "prefix hit suffix",
|
||||
value: "prefix done suffix",
|
||||
},
|
||||
]),
|
||||
).toBe(1);
|
||||
expect(editor.dirtyRows.value.get(0)?.get(0)).toBe("prefix done suffix");
|
||||
});
|
||||
|
||||
it("rejects readonly, stale, deleted, non-string and out-of-range targets", () => {
|
||||
const editor = createEditor(
|
||||
["first", undefined, "last"],
|
||||
|
||||
@@ -1071,12 +1071,12 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
|
||||
beginBatch();
|
||||
try {
|
||||
for (const change of changes) {
|
||||
const { rowId, col, previousValue, value } = change;
|
||||
const { rowId, col, previousValue, sourceValue = previousValue, value } = change;
|
||||
if (!Number.isInteger(rowId) || rowId < 0 || !Number.isInteger(col) || col < 0 || col >= result.value.columns.length || !canEditColumn(col) || deletedRows.value.has(rowId)) continue;
|
||||
const row = result.value.rows[rowId];
|
||||
if (!row) continue;
|
||||
const data = rowDataWithChanges(row, rowId);
|
||||
if (typeof data[col] !== "string" || data[col] !== previousValue || value === previousValue) continue;
|
||||
if (typeof data[col] !== "string" || data[col] !== sourceValue || value === previousValue) continue;
|
||||
const item: RowItem = { id: rowId, sourceIndex: rowId, data, isNew: false, isDeleted: false, isDirtyCol: [], status: "clean" };
|
||||
applyCellValueToItem(item, rowId, col, value, { preserveEmptyString: true });
|
||||
const currentValue = rowDataWithChanges(row, rowId)[col];
|
||||
|
||||
Reference in new issue
Block a user