Skip to content

Commit 41a90eb

Browse files
authored
DataGrid: Fix an issue in the setAria method that occurred when the value was undefined (#32274)
Co-authored-by: Alyar <>
1 parent af7d42e commit 41a90eb

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

packages/devextreme/js/__internal/grids/data_grid/summary/m_summary.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ export const renderSummaryCell = function (cell, options, setAria) {
4444
const $summaryItems: any = [];
4545

4646
if (!column.command && summaryItems) {
47-
for (let i = 0; i < summaryItems.length; i++) {
48-
const summaryItem = summaryItems[i];
47+
for (const summaryItem of summaryItems) {
4948
const text = gridCore.getSummaryText(summaryItem, options.summaryTexts);
5049
const $summaryItemElement = $('<div>')
5150
.css('textAlign', summaryItem.alignment || column.alignment)
@@ -55,7 +54,7 @@ export const renderSummaryCell = function (cell, options, setAria) {
5554
.toggleClass(DATAGRID_GROUP_TEXT_CONTENT_CLASS, options.rowType === 'group')
5655
.text(text);
5756

58-
setAria('label', `${column.caption} ${text}`, $summaryItemElement);
57+
setAria('label', `${column.caption ?? ''} ${text ?? ''}`, $summaryItemElement);
5958
$summaryItems.push($summaryItemElement);
6059
}
6160
$cell.append($summaryItems);

packages/devextreme/js/__internal/grids/grid_core/m_modules.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Callbacks from '@js/core/utils/callbacks';
99
// @ts-expect-error
1010
import { grep } from '@js/core/utils/common';
1111
import { each } from '@js/core/utils/iterator';
12-
import { isFunction } from '@js/core/utils/type';
12+
import { isDefined, isFunction } from '@js/core/utils/type';
1313
import { hasWindow } from '@js/core/utils/window';
1414
import errors from '@js/ui/widget/ui.errors';
1515

@@ -150,6 +150,10 @@ export class ModuleItem {
150150
value: string | number | boolean | undefined,
151151
$target: dxElementWrapper,
152152
) {
153+
if (!isDefined(value)) {
154+
return;
155+
}
156+
153157
const target = $target.get(0);
154158
const prefix = name !== 'role' && name !== 'id' ? 'aria-' : '';
155159
const normalizedValue = String(value).replace(/\s+/g, ' ').trim();

packages/devextreme/js/__internal/grids/grid_core/selection/m_selection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ export const rowsViewSelectionExtenderMixin = (Base: ModuleType<RowsView>) => cl
899899
$row
900900
.toggleClass(ROW_SELECTION_CLASS, isSelected === undefined ? false : isSelected)
901901
.find(`.${SELECT_CHECKBOX_CLASS}`).dxCheckBox('option', 'value', isSelected);
902-
that.setAria('selected', isSelected, $row);
902+
that.setAria('selected', String(isSelected), $row);
903903
}
904904
}
905905
});
@@ -949,7 +949,7 @@ export const rowsViewSelectionExtenderMixin = (Base: ModuleType<RowsView>) => cl
949949

950950
const selectionMode = this.option(SELECTION_MODE);
951951
if (selectionMode !== 'none') {
952-
this.setAria('selected', isSelected, $row);
952+
this.setAria('selected', String(isSelected), $row);
953953
}
954954
}
955955

packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/gridView.tests.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ QUnit.module('Grid view', {
532532
],
533533
totalItem: {
534534
summaryCells: [
535-
{ summaryType: 'count', value: 100 },
536-
{ summaryType: 'min', value: 0 },
537-
{ summaryType: 'max', value: 120001 }
535+
[{ summaryType: 'count', value: 100 }],
536+
[{ summaryType: 'min', value: 0 }],
537+
[{ summaryType: 'max', value: 120001 }]
538538
]
539539
}
540540
})
@@ -592,7 +592,7 @@ QUnit.module('Grid view', {
592592
],
593593
totalItem: {
594594
summaryCells: [
595-
{ summaryType: 'count', value: 100 }
595+
[{ summaryType: 'count', value: 100 }]
596596
]
597597
}
598598
})
@@ -1626,9 +1626,9 @@ QUnit.module('Synchronize columns', {
16261626
items: [{ values: [''] }],
16271627
totalItem: {
16281628
summaryCells: [
1629-
{ summaryType: 'count', value: 100 },
1630-
{ summaryType: 'min', value: 0 },
1631-
{ summaryType: 'max', value: 120001 }
1629+
[{ summaryType: 'count', value: 100 }],
1630+
[{ summaryType: 'min', value: 0 }],
1631+
[{ summaryType: 'max', value: 120001 }]
16321632
]
16331633
}
16341634
})
@@ -1663,9 +1663,9 @@ QUnit.module('Synchronize columns', {
16631663
items: [{ values: [''] }],
16641664
totalItem: {
16651665
summaryCells: [
1666-
{ summaryType: 'count', value: 100 },
1667-
{ summaryType: 'min', value: 0 },
1668-
{ summaryType: 'max', value: 120001 }
1666+
[{ summaryType: 'count', value: 100 }],
1667+
[{ summaryType: 'min', value: 0 }],
1668+
[{ summaryType: 'max', value: 120001 }]
16691669
]
16701670
}
16711671
})

0 commit comments

Comments
 (0)