Skip to content

Commit 62b597f

Browse files
DataGrid - Fix lookup filter changing to "(All)" after searching twice in another column (T1284002) (#32969)
1 parent 542ee5c commit 62b597f

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

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

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import DataGrid from 'devextreme-testcafe-models/dataGrid';
22
import TextBox from 'devextreme-testcafe-models/textBox';
3+
import SelectBox from 'devextreme-testcafe-models/selectBox';
34
import url from '../../../../helpers/getPageUrl';
45
import { createWidget } from '../../../../helpers/createWidget';
56
import { getData } from '../../helpers/generateDataSourceData';
@@ -230,3 +231,77 @@ test('DataGrid - filter range overlay in last column on Tab pressed moves focus
230231
},
231232
],
232233
}));
234+
235+
test('Lookup filter should not change to (All) after searching twice in another column (T1284002)', async (t) => {
236+
// arrange
237+
const dataGrid = new DataGrid('#container');
238+
const lookupFilterEditor = dataGrid.getFilterEditor(0, SelectBox);
239+
const textFilterEditor = dataGrid.getFilterEditor(1, TextBox);
240+
241+
// assert
242+
await t.expect(dataGrid.isReady()).ok();
243+
244+
// act
245+
await t.click(lookupFilterEditor.element);
246+
247+
// assert
248+
await t.expect(await lookupFilterEditor.isOpened()).ok();
249+
250+
// act
251+
const lookupList = await lookupFilterEditor.getList();
252+
const lookupItem = lookupList.getItem(1);
253+
await t.click(lookupItem.element);
254+
255+
// assert
256+
await t
257+
.expect(lookupFilterEditor.value)
258+
.eql('Lookup Item 1')
259+
.expect(dataGrid.dataRows.count)
260+
.eql(1);
261+
262+
// act
263+
await t.typeText(textFilterEditor.input, 'a');
264+
265+
// assert
266+
await t
267+
.expect(lookupFilterEditor.value)
268+
.eql('Lookup Item 1')
269+
.expect(dataGrid.dataRows.count)
270+
.eql(0);
271+
272+
// act
273+
await t.typeText(textFilterEditor.input, 'b');
274+
275+
// assert
276+
await t
277+
.expect(lookupFilterEditor.value)
278+
.eql('Lookup Item 1')
279+
.expect(dataGrid.dataRows.count)
280+
.eql(0);
281+
}).before(async () => createWidget('dxDataGrid', {
282+
dataSource: [
283+
{ ID: 1, Lookup: 1, Text: 'Item 1' },
284+
{ ID: 2, Lookup: 2, Text: 'Item 2' },
285+
{ ID: 3, Lookup: 3, Text: 'Item 3' },
286+
],
287+
keyExpr: 'ID',
288+
syncLookupFilterValues: true,
289+
filterRow: { visible: true },
290+
columns: [{
291+
dataField: 'Lookup',
292+
lookup: {
293+
valueExpr: 'ID',
294+
displayExpr: 'Text',
295+
dataSource: [
296+
{ ID: 1, Text: 'Lookup Item 1' },
297+
{ ID: 2, Text: 'Lookup Item 2' },
298+
{ ID: 3, Text: 'Lookup Item 3' },
299+
],
300+
},
301+
}, 'Text'],
302+
onEditorPreparing(e) {
303+
if (e.dataField === 'Text') {
304+
e.updateValueTimeout = 0;
305+
}
306+
},
307+
}));

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,12 @@ const columnHeadersView = (Base: ModuleType<ColumnHeadersView>) => class ColumnH
769769
|| !equalByValue(editorDataSource.__dataGridSourceFilter || null, filter);
770770

771771
if (shouldUpdateFilter) {
772+
const { selectedItem, items = [] } = editor.option();
773+
const hasSelectedItem = items.some((item) => equalByValue(item, selectedItem));
774+
if (!hasSelectedItem) {
775+
editor.option('items', [...items, selectedItem]);
776+
}
777+
772778
const lookupDataSource = gridCoreUtils.getWrappedLookupDataSource(column, dataSource, filter);
773779
editor.option('dataSource', lookupDataSource);
774780
}

0 commit comments

Comments
 (0)