Skip to content

Commit

Permalink
DataGrid: Fix closing editable cell when mouse pointer is dragged to …
Browse files Browse the repository at this point in the history
…copy data to other cells of the current row (T1203250) (DevExpress#26155)

Co-authored-by: Alyar <>
  • Loading branch information
Alyar666 committed Dec 8, 2023
1 parent 04c4bc6 commit 8de9cfd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@ export const editingModule = {
return isShowEditorAlways && allowEditing && editingController.editCell(e.rowIndex, columnIndex);
}

if (eventName === 'click' && startEditAction === 'dblClick') {
if (eventName === 'click' && startEditAction === 'dblClick' && this._pointerDownTarget === $targetElement.get(0)) {
const isError = false;
const withoutSaveEditData = row?.isNewRow;
editingController.closeEditCell(isError, withoutSaveEditData);
Expand All @@ -2581,6 +2581,7 @@ export const editingModule = {
}
},
_rowPointerDown(e) {
this._pointerDownTarget = e.event.target;
this._pointerDownTimeout = setTimeout(() => {
this._editCellByClick(e, 'down');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import typeUtils from 'core/utils/type';
import { addShadowDomStyles } from 'core/utils/shadow_dom';
import eventsEngine from 'events/core/events_engine';
import pointerEvents from 'events/pointer';
import { name as clickEventName } from 'events/click';
import { name as dblClickEventName } from 'events/dblclick';
import { triggerResizeEvent } from 'events/visibility_change';
import 'generic_light.css!';
import $ from 'jquery';
Expand Down Expand Up @@ -2696,7 +2698,7 @@ QUnit.module('Editing', {
rowsView.render($testElement);

// act
$testElement.find('td').first().trigger('dxdblclick');
$testElement.find('td').first().trigger(dblClickEventName);

// assert
assert.strictEqual(that.editingController.editCell.callCount, 1, 'count call editCell');
Expand All @@ -2707,14 +2709,47 @@ QUnit.module('Editing', {
sinon.spy(that.editingController, 'closeEditCell');

// act
$testElement.find('td').eq(1).trigger('dxclick');
$testElement.find('td').eq(1).trigger(pointerEvents.down);
$testElement.find('td').eq(1).trigger(clickEventName);
that.clock.tick(10);

// assert
assert.strictEqual(that.editingController.closeEditCell.callCount, 1, 'count call closeEditCell');
assert.strictEqual(getInputElements($testElement).length, 0, 'hasn\'t input');
});

// T1203250
QUnit.test('Batch mode with startEditAction is \'dblClick\' - Editing cell should not be closed when mouse pointer is dragged to copy data to other cells of the current row', function(assert) {
// arrange
const rowsView = this.rowsView;
const $testElement = $('#container');

$.extend(this.options.editing, {
allowUpdating: true,
mode: 'batch',
startEditAction: 'dblClick'
});
sinon.spy(this.editingController, 'closeEditCell');

rowsView.render($testElement);

// act
$(this.getCellElement(0, 0)).trigger(dblClickEventName);
this.clock.tick(10);

// assert
assert.strictEqual($(this.getCellElement(0, 0)).find('input').length, 1, 'has input');

// act
$(this.getCellElement(0, 0)).trigger(pointerEvents.down);
$(this.getCellElement(0, 1)).trigger(clickEventName);
this.clock.tick(10);

// assert
assert.strictEqual(this.editingController.closeEditCell.callCount, 0, 'count call closeEditCell');
assert.strictEqual($(this.getCellElement(0, 0)).find('input').length, 1, 'has input');
});

QUnit.test('Batch mode - Clicking on the edited cell should not close it when startEditAction is \'dblClick\'', function(assert) {
// arrange
const that = this;
Expand Down

0 comments on commit 8de9cfd

Please sign in to comment.