Skip to content

Commit e2f37d7

Browse files
authored
DataGrid: Editing - fix duplication of an undeleted row while creating a new row (T1293181) (#31934)
1 parent 48e44f4 commit e2f37d7

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
@@ -4886,6 +4886,33 @@ QUnit.module('Editing with real dataController', {
48864886
assert.equal(this.array.length, 7, 'items count not changed');
48874887
});
48884888

4889+
QUnit.test('Recovered row should have correct data when placed before inserted row in batch editing (T1293181)', function(assert) {
4890+
const testElement = $('#container');
4891+
4892+
$.extend(this.options.editing, {
4893+
mode: 'batch',
4894+
allowDeleting: true,
4895+
allowAdding: true,
4896+
newRowPosition: 'pageBottom',
4897+
texts: {
4898+
deleteRow: 'Delete',
4899+
undeleteRow: 'Undelete',
4900+
}
4901+
});
4902+
4903+
this.rowsView.render(testElement);
4904+
this.editingController.init();
4905+
4906+
this.addRow();
4907+
this.click(testElement.find('tbody > tr').eq(6), 'a:contains(Delete)');
4908+
this.click(testElement.find('tbody > tr').eq(6), '.dx-link-undelete');
4909+
4910+
const rows = this.getVisibleRows();
4911+
4912+
assert.strictEqual(rows.length, 8, 'items count is correct');
4913+
assert.deepEqual(rows[6].data, this.array[6], 'recovered row data is correct');
4914+
});
4915+
48894916
QUnit.test('Remove row when set onRowRemoving', function(assert) {
48904917
// arrange
48914918
const that = this;

0 commit comments

Comments
 (0)