Skip to content

Commit 2df5cc5

Browse files
authored
fix: pre-set value for editor validation on paste (#2368)
this fixes the issue that the new value is not present on the item when pasting, thus failing certain validations like required
1 parent 56148e2 commit 2df5cc5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/common/src/extensions/__tests__/slickCellExternalCopyManager.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ describe('CellExternalCopyManager', () => {
217217
plugin.init(gridStub);
218218
plugin.setDataItemValueForColumn(mockItem, mockColumns[0], 'some value');
219219

220-
expect(loadValSpy).toHaveBeenCalledWith(mockItem);
220+
const expectedItem = { ...mockItem, firstName: 'some value' };
221+
expect(loadValSpy).toHaveBeenCalledWith(expectedItem);
221222
expect(applyValSpy).toHaveBeenCalledWith(mockItem, 'some value');
222223
});
223224

@@ -232,7 +233,8 @@ describe('CellExternalCopyManager', () => {
232233
plugin.init(gridStub);
233234
plugin.setDataItemValueForColumn(mockItem, mockColumns[0], 'some value');
234235

235-
expect(loadValSpy).toHaveBeenCalledWith(mockItem);
236+
const expectedItem = { ...mockItem, firstName: 'some value' };
237+
expect(loadValSpy).toHaveBeenCalledWith(expectedItem);
236238
expect(applyValSpy).toHaveBeenCalledWith(mockItem, 'some value');
237239
expect(validationSpy).toHaveBeenCalled();
238240
expect(notifySpy).toHaveBeenCalledWith(expect.objectContaining({ validationResults }));

packages/common/src/extensions/slickCellExternalCopyManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export class SlickCellExternalCopyManager {
197197
cancelChanges: noop,
198198
commitChanges: noop,
199199
}) as Editor;
200-
editor.loadValue(item);
200+
editor.loadValue({ ...item, [columnDef.field]: value });
201201
const validationResults = editor.validate(undefined, value);
202202
if (!validationResults.valid) {
203203
const activeCell = this._grid.getActiveCell()!;

0 commit comments

Comments
 (0)