Skip to content

Commit 02fcd71

Browse files
committed
DataGrid: Editing - fix duplication of an undeleted row while creating a new row (T1293181) (#31934)
1 parent ea57982 commit 02fcd71

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

packages/devextreme/js/__internal/grids/grid_core/editing/m_editing.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,13 +1346,17 @@ class EditingControllerImpl extends modules.ViewController {
13461346
protected _removeChange(index) {
13471347
if (index >= 0) {
13481348
const changes = [...this.getChanges()];
1349-
const { key } = changes[index];
1349+
const { key, type } = changes[index];
13501350

13511351
this._removeInternalData(key);
13521352

1353-
this._updateInsertAfterOrBeforeKeys(changes, index);
1353+
if (type !== DATA_EDIT_DATA_REMOVE_TYPE) {
1354+
this._updateInsertAfterOrBeforeKeys(changes, index);
1355+
}
1356+
13541357
changes.splice(index, 1);
13551358
this._silentOption(EDITING_CHANGES_OPTION_NAME, changes);
1359+
13561360
if (equalByValue(this.option(EDITING_EDITROWKEY_OPTION_NAME), key)) {
13571361
this._resetEditIndices();
13581362
}

packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/editing.tests.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4941,6 +4941,33 @@ QUnit.module('Editing with real dataController', {
49414941
assert.equal(this.array.length, 7, 'items count not changed');
49424942
});
49434943

4944+
QUnit.test('Recovered row should have correct data when placed before inserted row in batch editing (T1293181)', function(assert) {
4945+
const testElement = $('#container');
4946+
4947+
$.extend(this.options.editing, {
4948+
mode: 'batch',
4949+
allowDeleting: true,
4950+
allowAdding: true,
4951+
newRowPosition: 'pageBottom',
4952+
texts: {
4953+
deleteRow: 'Delete',
4954+
undeleteRow: 'Undelete',
4955+
}
4956+
});
4957+
4958+
this.rowsView.render(testElement);
4959+
this.editingController.init();
4960+
4961+
this.addRow();
4962+
this.click(testElement.find('tbody > tr').eq(6), 'a:contains(Delete)');
4963+
this.click(testElement.find('tbody > tr').eq(6), '.dx-link-undelete');
4964+
4965+
const rows = this.getVisibleRows();
4966+
4967+
assert.strictEqual(rows.length, 8, 'items count is correct');
4968+
assert.deepEqual(rows[6].data, this.array[6], 'recovered row data is correct');
4969+
});
4970+
49444971
QUnit.test('Remove row when set onRowRemoving', function(assert) {
49454972
// arrange
49464973
const that = this;

0 commit comments

Comments
 (0)