Skip to content

Commit 57852b7

Browse files
authored
DataGrid: Fix view bouncing when scrolling down when there is grouping and a summary (T1270354) (#31088)
1 parent 6be1a97 commit 57852b7

8 files changed

+72
-6
lines changed
Loading
Loading
Loading
Loading
Loading
Loading

e2e/testcafe-devextreme/tests/dataGrid/common/scrolling.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import url from '../../../helpers/getPageUrl';
77
import { createWidget } from '../../../helpers/createWidget';
88
import { safeSizeTest } from '../../../helpers/safeSizeTest';
99
import { salesApiMock } from './apiMocks/salesApiMock';
10+
import { changeTheme } from '../../../helpers/changeTheme';
11+
import { Themes } from '../../../helpers/themes';
1012

1113
async function getMaxRightOffset(dataGrid: DataGrid): Promise<number> {
1214
const scrollWidth = await dataGrid.getScrollWidth();
@@ -1909,3 +1911,70 @@ test('DataGrid - The "row" parameter in the FocusedRowChanged event refers to a
19091911
delete (window as TestCaseWindow).dataGridScrollableEventValues;
19101912
}));
19111913
});
1914+
1915+
// T1270354
1916+
[
1917+
{ theme: Themes.genericLight, useNative: true },
1918+
{ theme: Themes.genericLight, useNative: false },
1919+
{ theme: Themes.materialBlue, useNative: true },
1920+
{ theme: Themes.materialBlue, useNative: false },
1921+
{ theme: Themes.fluentBlue, useNative: true },
1922+
{ theme: Themes.fluentBlue, useNative: false },
1923+
].forEach(({ theme, useNative }) => {
1924+
test(`Virtual ${useNative ? 'native' : 'simulated'} scrolling - Scrolling to the bottom should work correctly when there is a grouping and a summary (${theme} theme)`, async (t) => {
1925+
const dataGrid = new DataGrid('#container');
1926+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
1927+
1928+
await t
1929+
.expect(dataGrid.isReady())
1930+
.ok();
1931+
1932+
await dataGrid.scrollBy({ y: 10000 });
1933+
1934+
await t
1935+
.expect(await takeScreenshot(`T1270354-virtual-${useNative ? 'native' : 'simulated'}-scrolling-with-grouping-and-summary-${theme}.png`, '#container'))
1936+
.ok()
1937+
.expect(compareResults.isValid())
1938+
.ok(compareResults.errorMessages());
1939+
})
1940+
.before(async () => {
1941+
await changeTheme(theme);
1942+
await createWidget('dxDataGrid', {
1943+
dataSource: [...new Array(50)]
1944+
.fill(null)
1945+
.map((_, index) => ({
1946+
id: index,
1947+
machine: index,
1948+
totalTime: 1,
1949+
})),
1950+
keyExpr: 'id',
1951+
showBorders: true,
1952+
height: 400,
1953+
width: '100%',
1954+
columns: [
1955+
{
1956+
dataField: 'machine',
1957+
groupIndex: 0,
1958+
}, {
1959+
dataField: 'totalTime',
1960+
},
1961+
],
1962+
scrolling: {
1963+
mode: 'virtual',
1964+
useNative,
1965+
},
1966+
grouping: {
1967+
autoExpandAll: false,
1968+
},
1969+
summary: {
1970+
totalItems: [
1971+
{
1972+
column: 'totalTime',
1973+
summaryType: 'sum',
1974+
},
1975+
],
1976+
},
1977+
});
1978+
})
1979+
.after(async () => changeTheme(Themes.genericLight));
1980+
});

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ export class ResizingController extends modules.ViewController {
312312
const columnsController = this._columnsController;
313313
const visibleColumns = columnsController.getVisibleColumns();
314314
const columnAutoWidth = this.option('columnAutoWidth');
315-
const wordWrapEnabled = this.option('wordWrapEnabled');
316315
const hasUndefinedColumnWidth = visibleColumns.some((column) => !isDefined(column.width));
317316
let needBestFit = this._needBestFit();
318317
let hasMinWidth = false;
@@ -354,6 +353,8 @@ export class ResizingController extends modules.ViewController {
354353
return undefined;
355354
});
356355

356+
this._toggleContentMinHeight(this._hasHeight); // T1047239, T1270354
357+
357358
this._setVisibleWidths(visibleColumns, []);
358359

359360
const $element = this.component.$element();
@@ -366,8 +367,6 @@ export class ResizingController extends modules.ViewController {
366367
resetBestFitMode = true;
367368
}
368369

369-
this._toggleContentMinHeight(wordWrapEnabled); // T1047239
370-
371370
if ($element && $element.get(0) && this._maxWidth) {
372371
delete this._maxWidth;
373372
$element[0].style.maxWidth = '';
@@ -423,9 +422,7 @@ export class ResizingController extends modules.ViewController {
423422
this._setVisibleWidths(visibleColumns, resultWidths);
424423
}
425424

426-
if (wordWrapEnabled) {
427-
this._toggleContentMinHeight(false);
428-
}
425+
this._toggleContentMinHeight(false);
429426
});
430427
});
431428
}

0 commit comments

Comments
 (0)