Skip to content

Commit 914e209

Browse files
authored
DataGrid - Taps on cells do not activate cell editors in a detail DataGrid if this DataGrid is inside TabPanel on Android tablets (T1289237) (DevExpress#30403)
1 parent 7918787 commit 914e209

File tree

13 files changed

+153
-6
lines changed

13 files changed

+153
-6
lines changed

packages/devextreme/js/__internal/grids/grid_core/m_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ export default {
372372
normalizeSortingInfo,
373373

374374
getFormatByDataType(dataType) {
375-
// eslint-disable-next-line default-case
376375
switch (dataType) {
377376
case 'date':
378377
return 'shortDate';
@@ -590,6 +589,7 @@ export default {
590589
isElementInCurrentGrid(controller, $element) {
591590
if ($element && $element.length) {
592591
const $grid = $element.closest(`.${controller.getWidgetContainerClass()}`).parent();
592+
593593
return $grid.is(controller.component.$element());
594594
}
595595
return false;

packages/devextreme/js/__internal/grids/grid_core/views/m_columns_view.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ const subscribeToRowEvents = function (that, $table) {
7979
}
8080

8181
eventsEngine.on($table, 'touchstart touchend', '.dx-row', (e) => {
82+
// NOTE: checking for target only for mocks in qunits
83+
if (e?.event?.target && !gridCoreUtils.isElementInCurrentGrid(that, $(e.event.target))) {
84+
return;
85+
}
86+
8287
clearTimeout(timeoutId);
8388
if (e.type === 'touchstart') {
8489
touchTarget = e.target;
@@ -92,6 +97,11 @@ const subscribeToRowEvents = function (that, $table) {
9297
eventsEngine.on($table, [clickEventName, dblclickEvent, pointerEvents.down].join(' '), '.dx-row', that.createAction((e) => {
9398
const { event } = e;
9499

100+
// NOTE: checking for target only for mocks in qunits
101+
if (e?.event?.target && !gridCoreUtils.isElementInCurrentGrid(that, $(event.target))) {
102+
return;
103+
}
104+
95105
if (touchTarget) {
96106
event.target = touchTarget;
97107
event.currentTarget = touchCurrentTarget;
@@ -394,7 +404,7 @@ export class ColumnsView extends ColumnStateMixin(modules.View) {
394404
const visibleColumns = this._columnsController.getVisibleColumns();
395405
const rowOptions: any = $row.data('options');
396406
const columnIndex = $cell.index();
397-
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
407+
398408
const cellOptions = rowOptions && rowOptions.cells && rowOptions.cells[columnIndex];
399409
const column = cellOptions ? cellOptions.column : visibleColumns[columnIndex];
400410

@@ -1104,7 +1114,6 @@ export class ColumnsView extends ColumnStateMixin(modules.View) {
11041114
}
11051115

11061116
private needWaitAsyncTemplates() {
1107-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
11081117
return this.option('templatesRenderAsynchronously') && this.option('renderAsync') === false;
11091118
}
11101119

@@ -1154,11 +1163,9 @@ export class ColumnsView extends ColumnStateMixin(modules.View) {
11541163
const result: number[] = [];
11551164
const cellElements = $cellElements.toArray();
11561165

1157-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
11581166
(cellElements as HTMLElement[]).forEach((cell) => {
11591167
let width = cell.offsetWidth;
11601168

1161-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
11621169
if ((cell as any).getBoundingClientRect) {
11631170
const rect = getBoundingRect(cell);
11641171

packages/devextreme/testing/helpers/baseDataGridHelper.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import DataGrid from 'ui/data_grid';
2+
import gridCoreUtils from '__internal/grids/grid_core/m_utils';
23

34
import $ from 'jquery';
45

@@ -10,10 +11,13 @@ DataGrid.defaultOptions({
1011

1112
export const baseModuleConfig = {
1213
beforeEach: function() {
14+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
15+
gridCoreUtils.isElementInCurrentGrid = () => true;
1316
this.clock = sinon.useFakeTimers();
1417
},
1518
afterEach: function() {
1619
this.clock.restore();
20+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
1721
}
1822
};
1923

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import renderer from 'core/renderer';
1414
import themes from 'ui/themes';
1515
import DataGridWrapper from '../../helpers/wrappers/dataGridWrappers.js';
1616

17+
import gridCoreUtils from '__internal/grids/grid_core/m_utils';
18+
1719
const device = devices.real();
1820

1921
const CLICK_NAMESPACE = 'dxclick.dxDataGridAdaptivity';
@@ -68,10 +70,13 @@ QUnit.testStart(function() {
6870
QUnit.module('AdaptiveColumns', {
6971
beforeEach: function() {
7072
this.clock = sinon.useFakeTimers();
73+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
74+
gridCoreUtils.isElementInCurrentGrid = () => true;
7175
},
7276
afterEach: function() {
7377
this.dispose();
7478
this.clock.restore();
79+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
7580
}
7681
}, () => {
7782

@@ -2006,10 +2011,13 @@ QUnit.module('AdaptiveColumns', {
20062011
QUnit.module('API', {
20072012
beforeEach: function() {
20082013
this.clock = sinon.useFakeTimers();
2014+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
2015+
gridCoreUtils.isElementInCurrentGrid = () => true;
20092016
},
20102017
afterEach: function() {
20112018
this.dispose();
20122019
this.clock.restore();
2020+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
20132021
}
20142022
}, () => {
20152023

@@ -2294,10 +2302,13 @@ QUnit.module('API', {
22942302
QUnit.module('Editing', {
22952303
beforeEach: function() {
22962304
this.clock = sinon.useFakeTimers();
2305+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
2306+
gridCoreUtils.isElementInCurrentGrid = () => true;
22972307
},
22982308
afterEach: function() {
22992309
this.dispose();
23002310
this.clock.restore();
2311+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
23012312
}
23022313
}, () => {
23032314

@@ -3982,10 +3993,13 @@ QUnit.module('Editing', {
39823993
QUnit.module('Validation', {
39833994
beforeEach: function() {
39843995
this.clock = sinon.useFakeTimers();
3996+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
3997+
gridCoreUtils.isElementInCurrentGrid = () => true;
39853998
},
39863999
afterEach: function() {
39874000
this.dispose();
39884001
this.clock.restore();
4002+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
39894003
}
39904004
}, function() {
39914005

@@ -4498,13 +4512,16 @@ QUnit.module('Keyboard navigation', {
44984512

44994513
beforeEach: function() {
45004514
this.clock = sinon.useFakeTimers();
4515+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
4516+
gridCoreUtils.isElementInCurrentGrid = () => true;
45014517
},
45024518

45034519
afterEach: function() {
45044520
if(this.dispose) {
45054521
this.dispose();
45064522
}
45074523
this.clock.restore();
4524+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
45084525
}
45094526
}, function() {
45104527
QUnit.testInActiveWindow('Edit next an adaptive detail item by tab key', function(assert) {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import $ from 'jquery';
33
import 'ui/data_grid';
44

55
import dataGridMocks from '../../helpers/dataGridMocks.js';
6+
import gridCoreUtils from '__internal/grids/grid_core/m_utils';
67

78
const MockColumnsController = dataGridMocks.MockColumnsController;
89
const MockDataController = dataGridMocks.MockDataController;
@@ -23,6 +24,8 @@ QUnit.testStart(function() {
2324

2425
QUnit.module('Context menu', {
2526
beforeEach: function() {
27+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
28+
gridCoreUtils.isElementInCurrentGrid = () => true;
2629
this.element = function() {
2730
return $('#container');
2831
};
@@ -69,6 +72,7 @@ QUnit.module('Context menu', {
6972
},
7073
afterEach: function() {
7174
this.dispose();
75+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
7276
}
7377
}, () => {
7478

@@ -206,6 +210,8 @@ QUnit.module('Context menu', {
206210

207211
QUnit.module('Context menu with rowsView', {
208212
beforeEach: function() {
213+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
214+
gridCoreUtils.isElementInCurrentGrid = () => true;
209215
const that = this;
210216

211217
that.element = function() {
@@ -232,6 +238,7 @@ QUnit.module('Context menu with rowsView', {
232238
},
233239
afterEach: function() {
234240
this.dispose();
241+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
235242
}
236243
}, () => {
237244

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import $ from 'jquery';
2+
import gridCoreUtils from '__internal/grids/grid_core/m_utils';
23
import devices from '__internal/core/m_devices';
34
import fx from 'common/core/animation/fx';
45
import pointerEvents from 'common/core/events/pointer';
@@ -4202,6 +4203,8 @@ QUnit.module('Editing', baseModuleConfig, () => {
42024203

42034204
QUnit.module('Validation with virtual scrolling and rendering', {
42044205
beforeEach: function() {
4206+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
4207+
gridCoreUtils.isElementInCurrentGrid = () => true;
42054208
this.addHiddenColumn = () => {
42064209
this.columns.push({
42074210
dataField: 'hiddenField',
@@ -4249,6 +4252,7 @@ QUnit.module('Validation with virtual scrolling and rendering', {
42494252
},
42504253
afterEach: function() {
42514254
this.clock.restore();
4255+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
42524256
}
42534257
}, () => {
42544258

0 commit comments

Comments
 (0)