Skip to content

Commit

Permalink
DataGrid: Fix onRowClick call on "Save" click when edit mode is "form…
Browse files Browse the repository at this point in the history
…" (T848729)
  • Loading branch information
Alyar666 committed Jan 23, 2020
1 parent 92357e4 commit 6666d48
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/ui/grid_core/ui.grid_core.editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -2598,9 +2598,11 @@ module.exports = {
});
},
_rowClick: function(e) {
const isEditRow = $(e.rowElement).hasClass(EDIT_ROW);

e.event[TARGET_COMPONENT_NAME] = this.component;

if(!this._editCellByClick(e, 'click')) {
if(!this._editCellByClick(e, 'click') && !isEditRow) {
this.callBase.apply(this, arguments);
}
},
Expand Down
42 changes: 42 additions & 0 deletions testing/tests/DevExpress.ui.widgets.dataGrid/editing.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14930,6 +14930,48 @@ QUnit.test('The edit form should not be rerendered when setCellValue is set for
assert.strictEqual($editForm.find('.dx-datagrid-edit-form-item').first().find('.dx-texteditor-input').val(), 'Test', 'first cell value is changed');
});

// T848729
QUnit.test('The onRowClick event should not be fired when clicking on a save button in the edit form', function(assert) {
// arrange
this.options.loadingTimeout = 30;
this.options.repaintChangesOnly = true;
this.options.editing.texts = {
saveRowChanges: 'Save'
};
const onRowClick = this.options.onRowClick = sinon.spy((e) => {
this.editRow(e.rowIndex);
});
this.options.rowTemplate = function(container) {
$('<tbody class="dx-row dx-data-row"><tr><td></td></tr></tbody>').appendTo(container);
};
this.setupModules(this);
this.clock.tick(30);

const rowsView = this.rowsView;
const $testElement = $('#container');

rowsView.render($testElement);

this.editRow(0);
this.cellValue(0, 'name', 'Test');

let $rowElement = $(this.getRowElement(0));
const $saveButton = $rowElement.find('.dx-button').first();

// assert
assert.ok($rowElement.hasClass('dx-datagrid-edit-form'), 'has edit form');
assert.strictEqual($saveButton.text(), 'Save', 'has save button');

// act
$saveButton.trigger('dxclick');
this.clock.tick(30);

// assert
$rowElement = $(this.getRowElement(0));
assert.notOk($rowElement.hasClass('dx-datagrid-edit-form'), 'has not edit form');
assert.strictEqual(onRowClick.callCount, 0, 'onRowClick event is not fired');
});


QUnit.module('Editing - "popup" mode', {
beforeEach: function() {
Expand Down

0 comments on commit 6666d48

Please sign in to comment.