Skip to content

Commit

Permalink
TreeList and DataGrid always show the W1025 warning regardless of the…
Browse files Browse the repository at this point in the history
… height option value or CSS limiting the component height (T1196939) (#25974)
  • Loading branch information
pomahtri authored Nov 9, 2023
1 parent 486a4af commit f8adc00
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/__internal/grids/grid_core/views/m_rows_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ class RowsView extends ColumnsView {
that._scrollTop = 0;
that._scrollLeft = -1;
that._scrollRight = 0;
that._hasHeight = false;
that._hasHeight = undefined;
that._contentChanges = [];
dataController.loadingChanged.add((isLoading, messageText) => {
that.setLoading(isLoading, messageText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,6 @@ const VirtualScrollingRowsViewExtender = (function () {
const changeType = change && change.changeType;
const d: any = Deferred();

this.throwHeightWarningIfNeed();

const contentTable = contentElement.children().first();
if (changeType === 'append' || changeType === 'prepend') {
this.waitAsyncTemplates().done(() => {
Expand Down Expand Up @@ -749,7 +747,13 @@ const VirtualScrollingRowsViewExtender = (function () {
this.callBase.call(this, isLoading, messageText);
},

// NOTE: warning won't be thrown if height was specified and then removed,
// because for some reason `_hasHeight` is not updated properly in this case
throwHeightWarningIfNeed() {
if (this._hasHeight === undefined) {
return;
}

const needToThrow = !this._hasHeight && isVirtualPaging(this);
if (needToThrow && !this._heightWarningIsThrown) {
this._heightWarningIsThrown = true;
Expand All @@ -763,6 +767,8 @@ const VirtualScrollingRowsViewExtender = (function () {

that.callBase();

this.throwHeightWarningIfNeed();

if (that.component.$element() && !that._windowScroll && isElementInDom($element)) {
that._windowScroll = subscribeToExternalScrollers($element, (scrollPos) => {
if (!that._hasHeight && that._rowHeight) {
Expand Down
45 changes: 45 additions & 0 deletions testing/testcafe/tests/dataGrid/scrolling.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ClientFunction, Selector } from 'testcafe';
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import { removeStylesheetRulesFromPage, insertStylesheetRulesToPage } from '../../helpers/domUtils';
import url from '../../helpers/getPageUrl';
import createWidget from '../../helpers/createWidget';
import DataGrid from '../../model/dataGrid';
Expand Down Expand Up @@ -1624,8 +1625,52 @@ test('Warning should be thrown if scrolling is virtual and height is not specifi
scrolling: {
mode: 'virtual',
},
dataSource: [
{ column: 'value' },
],
}));

test('Warning should not be thrown if scrolling is virtual and height is specified with option', async (t) => {
const consoleMessages = await t.getBrowserConsoleMessages();
const warningExists = !!consoleMessages?.warn.find((message) => message.startsWith('W1025'));

await t.expect(warningExists).notOk();
}).before(async () => createWidget('dxDataGrid', {
scrolling: {
mode: 'virtual',
},
dataSource: [
{ column: 'value' },
],
height: 200,
}));

['height', 'max-height'].forEach((cssOption) => {
test(`Warning should not be thrown if scrolling is virtual and height is specified with css (${cssOption})`, async (t) => {
const consoleMessages = await t.getBrowserConsoleMessages();
const warningExists = !!consoleMessages?.warn.find((message) => message.startsWith('W1025'));

await t.expect(warningExists).notOk();
}).before(async () => {
await insertStylesheetRulesToPage(`
#container {
${cssOption}: 200px;
}
`);

await createWidget('dxDataGrid', {
scrolling: {
mode: 'virtual',
},
dataSource: [
{ column: 'value' },
],
});
}).after(async () => {
await removeStylesheetRulesFromPage();
});
});

// T1194796
test('The row alternation should display correctly when grouping and virtual scrolling are enabled', async (t) => {
const dataGrid = new DataGrid('#container');
Expand Down

0 comments on commit f8adc00

Please sign in to comment.