From 6078ef55fa3539ccc104ac6f6c6e3ab9d7e08aa9 Mon Sep 17 00:00:00 2001 From: Roman Semenov Date: Tue, 12 Sep 2023 09:21:18 +0400 Subject: [PATCH] fix --- .../virtual_scrolling/m_virtual_scrolling.ts | 11 +++++++++++ packages/devextreme/js/ui/widget/ui.errors.js | 5 +++++ .../testing/testcafe/tests/dataGrid/scrolling.ts | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/packages/devextreme/js/__internal/grids/grid_core/virtual_scrolling/m_virtual_scrolling.ts b/packages/devextreme/js/__internal/grids/grid_core/virtual_scrolling/m_virtual_scrolling.ts index fcaf3595c554..afd07827d5b5 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/virtual_scrolling/m_virtual_scrolling.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/virtual_scrolling/m_virtual_scrolling.ts @@ -8,6 +8,7 @@ import { getOuterHeight } from '@js/core/utils/size'; import { isDefined } from '@js/core/utils/type'; import { getWindow } from '@js/core/utils/window'; import LoadIndicator from '@js/ui/load_indicator'; +import errors from '@js/ui/widget/ui.errors'; import gridCoreUtils from '../m_utils'; import { subscribeToExternalScrollers, VirtualScrollController } from './m_virtual_scrolling_core'; @@ -484,6 +485,8 @@ 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(() => { @@ -746,6 +749,14 @@ const VirtualScrollingRowsViewExtender = (function () { this.callBase.call(this, isLoading, messageText); }, + throwHeightWarningIfNeed() { + const needToThrow = !this._hasHeight && isVirtualPaging(this); + if (needToThrow && !this._heightWarningIsThrown) { + this._heightWarningIsThrown = true; + errors.log('W1025'); + } + }, + _resizeCore() { const that = this; const $element = that.element(); diff --git a/packages/devextreme/js/ui/widget/ui.errors.js b/packages/devextreme/js/ui/widget/ui.errors.js index 2fed5cea2fd3..87affcbadb65 100644 --- a/packages/devextreme/js/ui/widget/ui.errors.js +++ b/packages/devextreme/js/ui/widget/ui.errors.js @@ -360,4 +360,9 @@ export default errorUtils(errors.ERROR_MESSAGES, { * @name ErrorsUIWidgets.W1024 */ W1024: 'The client-side export is enabled. Implement the \'onExporting\' function.', + + /** + * @name ErrorsUIWidgets.W1025 + */ + W1025: '\'scrolling.mode\' is set to \'virtual\' or \'infinite\'. Specify height for the component', }); diff --git a/packages/devextreme/testing/testcafe/tests/dataGrid/scrolling.ts b/packages/devextreme/testing/testcafe/tests/dataGrid/scrolling.ts index 04664e6a7a21..f5f53e5dd2d4 100644 --- a/packages/devextreme/testing/testcafe/tests/dataGrid/scrolling.ts +++ b/packages/devextreme/testing/testcafe/tests/dataGrid/scrolling.ts @@ -1609,3 +1609,14 @@ test('Restoring focus on re-rendering should be done without unexpected scrollin masterDetail: { enabled: true }, }); }); + +test('Warning should be thrown if scrolling is virtual and height is not specified', async (t) => { + const consoleMessages = await t.getBrowserConsoleMessages(); + const warningExists = !!consoleMessages?.warn.find((message) => message.startsWith('W1025')); + + await t.expect(warningExists).ok(); +}).before(async () => createWidget('dxDataGrid', { + scrolling: { + mode: 'virtual', + }, +}));