From d12012e4686e714073ad446934324e0fb525b506 Mon Sep 17 00:00:00 2001 From: Andrey Dolzhikov Date: Fri, 8 Sep 2023 09:35:50 +0300 Subject: [PATCH] T1187314 - DataGrid displays an incorrect row count in "aria-label" if there is no data after filtering (#25551) Co-authored-by: Andrey Dolzhikov --- .../grids/grid_core/views/m_grid_view.ts | 3 ++- .../testing/testcafe/model/dataGrid/index.ts | 4 ++++ .../tests/dataGrid/accessibility/bugs.ts | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 packages/devextreme/testing/testcafe/tests/dataGrid/accessibility/bugs.ts diff --git a/packages/devextreme/js/__internal/grids/grid_core/views/m_grid_view.ts b/packages/devextreme/js/__internal/grids/grid_core/views/m_grid_view.ts index fee6dbee21e6..2862c84985ed 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/views/m_grid_view.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/views/m_grid_view.ts @@ -119,10 +119,11 @@ const resizingControllerMembers = { }, _setAriaLabel() { + const totalItemsCount = Math.max(0, this._dataController.totalItemsCount()); this.component.setAria('label', messageLocalization.format( this._getWidgetAriaLabel(), // @ts-expect-error - this._dataController.totalItemsCount(), + totalItemsCount, this.component.columnCount(), ), this.component.$element().children(`.${GRIDBASE_CONTAINER_CLASS}`)); }, diff --git a/packages/devextreme/testing/testcafe/model/dataGrid/index.ts b/packages/devextreme/testing/testcafe/model/dataGrid/index.ts index 5c66070fad18..b215bb871dad 100644 --- a/packages/devextreme/testing/testcafe/model/dataGrid/index.ts +++ b/packages/devextreme/testing/testcafe/model/dataGrid/index.ts @@ -106,6 +106,10 @@ export default class DataGrid extends Widget { return Widget.addClassPrefix(this.getName(), className); } + getContainer(): Selector { + return this.element.find(`.${CLASS.dataGrid}`); + } + getHeaders(): Headers { return new Headers(this.element.find(`.${this.addWidgetPrefix(CLASS.headers)}`), this.getName()); } diff --git a/packages/devextreme/testing/testcafe/tests/dataGrid/accessibility/bugs.ts b/packages/devextreme/testing/testcafe/tests/dataGrid/accessibility/bugs.ts new file mode 100644 index 000000000000..c8ed2e5d3eb5 --- /dev/null +++ b/packages/devextreme/testing/testcafe/tests/dataGrid/accessibility/bugs.ts @@ -0,0 +1,23 @@ +import createWidget from '../../../helpers/createWidget'; +import url from '../../../helpers/getPageUrl'; +import DataGrid from '../../../model/dataGrid'; + +fixture`Accessibility bugs` + .page(url(__dirname, '../../container.html')); + +test('T1187314 - DataGrid displays an incorrect row count in "aria-label" if there is no data after filtering', async (t) => { + const dataGrid = new DataGrid('#container'); + + await t + .expect(dataGrid.getContainer().getAttribute('aria-label')) + .eql('Data grid with 0 rows and 2 columns'); +}).before(async () => createWidget('dxDataGrid', { + keyExpr: 'id', + dataSource: [{ + id: 0, + data: 'A', + }], + filterRow: { visible: true }, + filterValue: ['id', '=', '1'], + scrolling: { mode: 'infinite' }, +}));