Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrid: Fix onRowClick call on "Save" click when edit mode is "form" (T848729) #11615

Merged
merged 2 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 isEditForm = $(e.rowElement).hasClass(this.addWidgetPrefix(EDIT_FORM_CLASS));

e.event[TARGET_COMPONENT_NAME] = this.component;

if(!this._editCellByClick(e, 'click')) {
if(!this._editCellByClick(e, 'click') && !isEditForm) {
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