Skip to content

Commit e2bc8d8

Browse files
authored
T1272535: DataGrid - fix base sensitivity search in lookup column (#28863)
Co-authored-by: Vladimir Bushmanov <[email protected]>
1 parent 4e9b4bc commit e2bc8d8

File tree

4 files changed

+53
-6
lines changed

4 files changed

+53
-6
lines changed

e2e/testcafe-devextreme/tests/dataGrid/searchPanel.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,44 @@ safeSizeTest('searchPanel has correct view inside masterDetail', async (t) => {
5151
},
5252
});
5353
}).after(async () => { await changeTheme(Themes.genericLight); });
54+
55+
// T1272535
56+
safeSizeTest('Base sensitivity search should accept rows with accent letters in lookup columns', async (t) => {
57+
const dataGrid = new DataGrid('#container');
58+
59+
await t
60+
.click(dataGrid.getSearchBox().input)
61+
.pressKey('a');
62+
63+
await t.expect(dataGrid.dataRows.count).eql(2);
64+
await t.expect(dataGrid.dataRows.withText('another').exists).ok();
65+
await t.expect(dataGrid.dataRows.withText('ánother').exists).ok();
66+
}, [800, 800]).before(async () => createWidget('dxDataGrid', {
67+
dataSource: {
68+
store: [
69+
{ id: 1, text: 'tešt', lookup: 1 },
70+
{ id: 2, text: 'test', lookup: 2 },
71+
{ id: 3, text: 'chest', lookup: 3 },
72+
],
73+
langParams: {
74+
locale: 'en-US',
75+
collatorOptions: {
76+
sensitivity: 'base',
77+
},
78+
},
79+
},
80+
keyExpr: 'id',
81+
searchPanel: { visible: true },
82+
columns: ['id', 'text', {
83+
dataField: 'lookup',
84+
lookup: {
85+
dataSource: [
86+
{ id: 1, text: 'another' },
87+
{ id: 2, text: 'ánother' },
88+
{ id: 3, text: 'other' },
89+
],
90+
valueExpr: 'id',
91+
displayExpr: 'text',
92+
},
93+
}],
94+
}));

packages/devextreme/js/__internal/grids/grid_core/search/m_search.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import domAdapter from '@js/core/dom_adapter';
44
import $ from '@js/core/renderer';
55
// @ts-expect-error
66
import { compileGetter, toComparable } from '@js/core/utils/data';
7+
import type { LangParams } from '@js/data';
78
import dataQuery from '@js/data/query';
89
import messageLocalization from '@js/localization/message';
910

@@ -57,8 +58,11 @@ const dataController = (
5758
}
5859

5960
protected _calculateAdditionalFilter(): Filter {
61+
const dataSource = this._dataController?.getDataSource?.();
62+
const langParams = dataSource?.loadOptions?.()?.langParams;
63+
6064
const filter = super._calculateAdditionalFilter();
61-
const searchFilter = this.calculateSearchFilter(this.option('searchPanel.text'));
65+
const searchFilter = this.calculateSearchFilter(this.option('searchPanel.text'), langParams);
6266

6367
return gridCoreUtils.combineFilters([filter, searchFilter]);
6468
}
@@ -67,8 +71,7 @@ const dataController = (
6771
this.option('searchPanel.text', text);
6872
}
6973

70-
private calculateSearchFilter(text: string | undefined): Filter {
71-
let i;
74+
private calculateSearchFilter(text: string | undefined, langParams?: LangParams): Filter {
7275
let column;
7376
const columns = this._columnsController.getColumns();
7477
const searchVisibleColumnsOnly = this.option('searchPanel.searchVisibleColumnsOnly');
@@ -88,17 +91,18 @@ const dataController = (
8891
}
8992
}
9093

91-
for (i = 0; i < columns.length; i++) {
94+
for (let i = 0; i < columns.length; i++) {
9295
column = columns[i];
9396

9497
if (searchVisibleColumnsOnly && !column.visible) continue;
9598

9699
if (allowSearch(column) && column.calculateFilterExpression) {
97100
lookup = column.lookup;
98101
const filterValue = parseValue(column, text);
99-
if (lookup && lookup.items) {
102+
103+
if (lookup?.items) {
100104
// @ts-expect-error
101-
dataQuery(lookup.items).filter(column.createFilterExpression.call({ dataField: lookup.displayExpr, dataType: lookup.dataType, calculateFilterExpression: column.calculateFilterExpression }, filterValue, null, 'search')).enumerate().done(onQueryDone);
105+
dataQuery(lookup.items, { langParams }).filter(column.createFilterExpression.call({ dataField: lookup.displayExpr, dataType: lookup.dataType, calculateFilterExpression: column.calculateFilterExpression }, filterValue, null, 'search')).enumerate().done(onQueryDone);
102106
} else if (filterValue !== undefined) {
103107
filters.push(column.createFilterExpression(filterValue, null, 'search'));
104108
}

packages/devextreme/js/data/data_source.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ interface DataSourceOptionsStub<
447447
expand?: Array<string> | string;
448448
filter?: FilterDescriptor | Array<FilterDescriptor>;
449449
group?: GroupDescriptor<TItem> | Array<GroupDescriptor<TItem>>;
450+
langParams?: LangParams;
450451
map?: ((dataItem: TStoreItem) => TMappedItem);
451452
onChanged?: ((e: { readonly changes?: Array<TMappedItem> }) => void);
452453
onLoadError?: ((error: { readonly message?: string }) => void);

packages/devextreme/ts/dx.all.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5417,6 +5417,7 @@ declare module DevExpress.data {
54175417
expand?: Array<string> | string;
54185418
filter?: FilterDescriptor | Array<FilterDescriptor>;
54195419
group?: GroupDescriptor<TItem> | Array<GroupDescriptor<TItem>>;
5420+
langParams?: LangParams;
54205421
map?: (dataItem: TStoreItem) => TMappedItem;
54215422
onChanged?: (e: { readonly changes?: Array<TMappedItem> }) => void;
54225423
onLoadError?: (error: { readonly message?: string }) => void;

0 commit comments

Comments
 (0)