Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import DataGrid from 'devextreme-testcafe-models/dataGrid';
import TextBox from 'devextreme-testcafe-models/textBox';
import SelectBox from 'devextreme-testcafe-models/selectBox';
import url from '../../../../helpers/getPageUrl';
import { createWidget } from '../../../../helpers/createWidget';
import { getData } from '../../helpers/generateDataSourceData';
Expand Down Expand Up @@ -230,3 +231,77 @@ test('DataGrid - filter range overlay in last column on Tab pressed moves focus
},
],
}));

test('Lookup filter should not change to (All) after searching twice in another column (T1284002)', async (t) => {
// arrange
const dataGrid = new DataGrid('#container');
const lookupFilterEditor = dataGrid.getFilterEditor(0, SelectBox);
const textFilterEditor = dataGrid.getFilterEditor(1, TextBox);

// assert
await t.expect(dataGrid.isReady()).ok();

// act
await t.click(lookupFilterEditor.element);

// assert
await t.expect(await lookupFilterEditor.isOpened()).ok();

// act
const lookupList = await lookupFilterEditor.getList();
const lookupItem = lookupList.getItem(1);
await t.click(lookupItem.element);

// assert
await t
.expect(lookupFilterEditor.value)
.eql('Lookup Item 1')
.expect(dataGrid.dataRows.count)
.eql(1);

// act
await t.typeText(textFilterEditor.input, 'a');

// assert
await t
.expect(lookupFilterEditor.value)
.eql('Lookup Item 1')
.expect(dataGrid.dataRows.count)
.eql(0);

// act
await t.typeText(textFilterEditor.input, 'b');

// assert
await t
.expect(lookupFilterEditor.value)
.eql('Lookup Item 1')
.expect(dataGrid.dataRows.count)
.eql(0);
}).before(async () => createWidget('dxDataGrid', {
dataSource: [
{ ID: 1, Lookup: 1, Text: 'Item 1' },
{ ID: 2, Lookup: 2, Text: 'Item 2' },
{ ID: 3, Lookup: 3, Text: 'Item 3' },
],
keyExpr: 'ID',
syncLookupFilterValues: true,
filterRow: { visible: true },
columns: [{
dataField: 'Lookup',
lookup: {
valueExpr: 'ID',
displayExpr: 'Text',
dataSource: [
{ ID: 1, Text: 'Lookup Item 1' },
{ ID: 2, Text: 'Lookup Item 2' },
{ ID: 3, Text: 'Lookup Item 3' },
],
},
}, 'Text'],
onEditorPreparing(e) {
if (e.dataField === 'Text') {
e.updateValueTimeout = 0;
}
},
}));
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,12 @@ const columnHeadersView = (Base: ModuleType<ColumnHeadersView>) => class ColumnH
|| !equalByValue(editorDataSource.__dataGridSourceFilter || null, filter);

if (shouldUpdateFilter) {
const { selectedItem, items = [] } = editor.option();
const hasSelectedItem = items.some((item) => equalByValue(item, selectedItem));
if (!hasSelectedItem) {
editor.option('items', [...items, selectedItem]);
Comment on lines +772 to +775
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

selectedItem for SelectBox defaults to null (e.g., when the filter value is cleared / "(All)"), so this logic can append null/undefined into items. That can introduce an empty lookup entry (or trigger template/getter edge cases) and will also run on fullReload when no lookup value is selected. Please guard this block so it only mutates items when selectedItem is defined (non-null) and items is an array; otherwise skip updating items.

Suggested change
const { selectedItem, items = [] } = editor.option();
const hasSelectedItem = items.some((item) => equalByValue(item, selectedItem));
if (!hasSelectedItem) {
editor.option('items', [...items, selectedItem]);
const { selectedItem, items } = editor.option();
if (isDefined(selectedItem) && Array.isArray(items)) {
const hasSelectedItem = items.some((item) => equalByValue(item, selectedItem));
if (!hasSelectedItem) {
editor.option('items', [...items, selectedItem]);
}

Copilot uses AI. Check for mistakes.
}

const lookupDataSource = gridCoreUtils.getWrappedLookupDataSource(column, dataSource, filter);
editor.option('dataSource', lookupDataSource);
}
Expand Down
Loading