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,13 @@ const columnHeadersView = (Base: ModuleType<ColumnHeadersView>) => class ColumnH
|| !equalByValue(editorDataSource.__dataGridSourceFilter || null, filter);

if (shouldUpdateFilter) {
const selectedItem = editor.option('selectedItem');
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: it is preferable to use destructurization from options() instead of getting option by name
in that case it will not lose types if editor properly typed

const { selectedItem, items = [] } = editor.option();

const items = editor.option('items') ?? [];
const hasSelectedItem = items.some((item) => equalByValue(item, selectedItem));
if (!hasSelectedItem) {
editor.option('items', [...items, selectedItem]);
}

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