Skip to content

Commit 6efc5ff

Browse files
authored
DataGrid - FilterRow's searchBox's aria-label should be customizable - T1290381 (DevExpress#30406)
1 parent c3fb276 commit 6efc5ff

File tree

2 files changed

+38
-4
lines changed
  • e2e/testcafe-devextreme/tests/dataGrid/common/filterRow
  • packages/devextreme/js/__internal/grids/grid_core/filter

2 files changed

+38
-4
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,38 @@ test('DataGrid - The `between` filter dropdown sticks to the viewport edge durin
259259
columnWidth: 400,
260260
width: 500,
261261
}));
262+
263+
// T1290381
264+
test('DataGrid - filter row\'s search-box\'s aria-label should be customizable via localization', async (t) => {
265+
const dataGrid = new DataGrid('#container');
266+
const filterEditor = dataGrid.getFilterEditor(0, FilterTextBox);
267+
268+
await dataGrid.isReady();
269+
270+
await t
271+
.expect(filterEditor.menuButton.getAttribute('aria-label'))
272+
.eql('custom text');
273+
}).before(async (t) => {
274+
await t.eval(() => {
275+
(window as any).DevExpress.localization.loadMessages({
276+
// Replace "en" with the target locale of the dictionary
277+
en: {
278+
'dxDataGrid-ariaSearchBox': 'custom text',
279+
},
280+
});
281+
});
282+
283+
return createWidget('dxDataGrid', {
284+
columns: [{
285+
dataField: 'test',
286+
dataType: 'string',
287+
}],
288+
filterRow: {
289+
visible: true,
290+
},
291+
});
292+
}).after(async (t) => {
293+
// To reset localization messages
294+
await t
295+
.eval(() => location.reload());
296+
});

packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ const EDITORS_INPUT_SELECTOR = 'input:not([type=\'hidden\'])';
7676

7777
const BETWEEN_OPERATION_DATA_TYPES = ['date', 'datetime', 'number'];
7878

79-
const ARIA_SEARCH_BOX = messageLocalization.format('dxDataGrid-ariaSearchBox');
80-
8179
function isOnClickApplyFilterMode(that) {
8280
return that.option('filterRow.applyFilter') === 'onClick';
8381
}
@@ -581,6 +579,7 @@ const columnHeadersView = (Base: ModuleType<ColumnHeadersView>) => class ColumnH
581579
};
582580

583581
const editorFactoryController = this._editorFactoryController;
582+
const ariaSearchBox = messageLocalization.format('dxDataGrid-ariaSearchBox');
584583

585584
that._createComponent($menu, Menu, {
586585
// @ts-expect-error
@@ -591,15 +590,15 @@ const columnHeadersView = (Base: ModuleType<ColumnHeadersView>) => class ColumnH
591590
showFirstSubmenuMode: 'onHover',
592591
hideSubmenuOnMouseLeave: true,
593592
items: [{
594-
name: getColumnSelectedFilterOperation(that, column) || ARIA_SEARCH_BOX,
593+
name: getColumnSelectedFilterOperation(that, column) || ariaSearchBox,
595594
disabled: !column.filterOperations?.length,
596595
icon: OPERATION_ICONS[getColumnSelectedFilterOperation(that, column) || 'default'],
597596
selectable: false,
598597
items: that._getFilterOperationMenuItems(column),
599598
}],
600599
onItemRendered: ({ itemElement, itemData }) => {
601600
if (itemData?.items && itemData?.name) {
602-
const labelText = that._getOperationDescriptionFromDescriptor(itemData.name) || ARIA_SEARCH_BOX;
601+
const labelText = that._getOperationDescriptionFromDescriptor(itemData.name) || ariaSearchBox;
603602
this.setAria('label', labelText, $(itemElement));
604603
}
605604
},

0 commit comments

Comments
 (0)