Skip to content

Commit 84d4103

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#30487)
1 parent 4c9036c commit 84d4103

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
@@ -78,6 +78,11 @@ const subscribeToRowEvents = function (that, $table) {
7878
}
7979

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

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

@@ -1102,7 +1112,6 @@ export class ColumnsView extends ColumnStateMixin(modules.View) {
11021112
}
11031113

11041114
private needWaitAsyncTemplates() {
1105-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
11061115
return this.option('templatesRenderAsynchronously') && this.option('renderAsync') === false;
11071116
}
11081117

@@ -1152,11 +1161,9 @@ export class ColumnsView extends ColumnStateMixin(modules.View) {
11521161
const result: number[] = [];
11531162
const cellElements = $cellElements.toArray();
11541163

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

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

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';
@@ -4201,6 +4202,8 @@ QUnit.module('Editing', baseModuleConfig, () => {
42014202

42024203
QUnit.module('Validation with virtual scrolling and rendering', {
42034204
beforeEach: function() {
4205+
this.oldIsElementInCurrentGrid = gridCoreUtils.isElementInCurrentGrid;
4206+
gridCoreUtils.isElementInCurrentGrid = () => true;
42044207
this.addHiddenColumn = () => {
42054208
this.columns.push({
42064209
dataField: 'hiddenField',
@@ -4248,6 +4251,7 @@ QUnit.module('Validation with virtual scrolling and rendering', {
42484251
},
42494252
afterEach: function() {
42504253
this.clock.restore();
4254+
gridCoreUtils.isElementInCurrentGrid = this.oldIsElementInCurrentGrid;
42514255
}
42524256
}, () => {
42534257

0 commit comments

Comments
 (0)