From 3c4c4b07fb4e40fa585dbfa8551b6139c4462972 Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Fri, 22 Nov 2024 20:11:02 +0800 Subject: [PATCH 01/10] fix --- .../js/__internal/grids/grid_core/filter/m_filter_row.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts b/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts index 496779c3de95..91d80a3cb6e1 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts @@ -162,7 +162,7 @@ const normalizeFilterValue = function (that, filterValue, column, $editorContain }; const updateFilterValue = function (that, options) { - const value = options.value === '' ? null : options.value; + const { value } = options; const $editorContainer = options.container; const column = that._columnsController.columnOption(options.column.index); const filterValue = getFilterValue(that, column.index, $editorContainer); From a876f47e5f88ceddd63e60905de375427c56c624 Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Mon, 25 Nov 2024 19:41:14 +0800 Subject: [PATCH 02/10] test --- .../dataGrid/headerFilter/headerFilter.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/e2e/testcafe-devextreme/tests/dataGrid/headerFilter/headerFilter.ts b/e2e/testcafe-devextreme/tests/dataGrid/headerFilter/headerFilter.ts index 15fd2fd294f2..e3238a7e285a 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/headerFilter/headerFilter.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/headerFilter/headerFilter.ts @@ -10,6 +10,46 @@ fixture.disablePageReloads`Header Filter` const GRID_CONTAINER = '#container'; +test('Data should be filtered if (Blank) is selected in the header filter (T1257261)', async (t) => { + const result: string[] = []; + const dataGrid = new DataGrid(GRID_CONTAINER); + const headerCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(1); + const dataCell = dataGrid.getDataRow(0).getDataCell(0); + const filterIconElement = headerCell.getFilterIcon(); + const headerFilter = new HeaderFilter(); + const buttons = headerFilter.getButtons(); + const list = headerFilter.getList(); + + await t.click(filterIconElement) + .click(list.getItem(1).element) + .click(buttons.nth(0)); + + result[0] = await dataCell.element().innerText; + + await t.click(filterIconElement) + .click(filterIconElement) + .click(list.getItem(1).element) + .click(list.getItem(0).element) + .click(buttons.nth(0)); + + result[1] = await dataCell.element().innerText; + + await t.expect(result[0]).eql('1') + .expect(result[1]).eql('2'); +}).before(async () => createWidget('dxDataGrid', { + dataSource: [ + { ID: 1, Text: 'Item 1' }, + { ID: 2, Text: '' }, + { ID: 3, Text: 'Item 3' }, + ], + keyExpr: 'ID', + showBorders: true, + remoteOperations: true, + headerFilter: { visible: true }, + filterRow: { visible: true }, + filterPanel: { visible: true }, +})); + test('HeaderFilter icon should be grayed out after the clearFilter call (T1193648)', async (t) => { const { takeScreenshot, compareResults } = createScreenshotsComparer(t); const dataGrid = new DataGrid(GRID_CONTAINER); From 005c82d40620fd35a9b115fa9c178635b3a538d9 Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Fri, 6 Dec 2024 19:41:14 +0800 Subject: [PATCH 03/10] fix side-effect --- packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js b/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js index e2f693daa68c..d6ac9a90d182 100644 --- a/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js +++ b/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js @@ -51,7 +51,8 @@ const getTextEditorConfig = function(options) { const needDelayedUpdate = options.parentType === 'filterRow' || options.parentType === 'searchPanel'; const isInputOrKeyUpEvent = e.event && (e.event.type === 'input' || e.event.type === 'keyup'); const updateValue = function(e, notFireEvent) { - options && options.setValue(e.value, notFireEvent); + const value = isInputOrKeyUpEvent && e.value === '' ? null : e.value; + options && options.setValue(value, notFireEvent); }; clearTimeout(data.valueChangeTimeout); From 87b6db5eb1dbd21af4131dbdcabd9af3f442fc71 Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Mon, 9 Dec 2024 11:04:37 +0800 Subject: [PATCH 04/10] fix --- .../js/ui/shared/ui.editor_factory_mixin.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js b/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js index d6ac9a90d182..ee54a4e11b54 100644 --- a/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js +++ b/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js @@ -49,20 +49,20 @@ const getTextEditorConfig = function(options) { onValueChanged: function(e) { const needDelayedUpdate = options.parentType === 'filterRow' || options.parentType === 'searchPanel'; - const isInputOrKeyUpEvent = e.event && (e.event.type === 'input' || e.event.type === 'keyup'); - const updateValue = function(e, notFireEvent) { - const value = isInputOrKeyUpEvent && e.value === '' ? null : e.value; - options && options.setValue(value, notFireEvent); + const notChangedProgrammatically = isDefined(e.event); + const updateValue = function(newValue, notFireEvent) { + options && options.setValue(newValue, notFireEvent); }; clearTimeout(data.valueChangeTimeout); - if(isInputOrKeyUpEvent && needDelayedUpdate) { + if(notChangedProgrammatically && needDelayedUpdate) { sharedData.valueChangeTimeout = data.valueChangeTimeout = setTimeout(function() { - updateValue(e, data.valueChangeTimeout !== sharedData.valueChangeTimeout); + const value = e.value === '' ? null : e.value; + updateValue(value, data.valueChangeTimeout !== sharedData.valueChangeTimeout); }, isDefined(options.updateValueTimeout) ? options.updateValueTimeout : 0); } else { - updateValue(e); + updateValue(e.value); } }, onKeyDown: function(e) { From e8eba16c6d2938684d0270b00d0695306521fd45 Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Mon, 9 Dec 2024 13:07:04 +0800 Subject: [PATCH 05/10] additional test --- .../tests/dataGrid/filterRow/filterRow.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts b/e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts index 592c53de5a70..1c4a985f1779 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts @@ -9,6 +9,49 @@ import { getNumberData } from '../helpers/generateDataSourceData'; fixture.disablePageReloads`FilterRow` .page(url(__dirname, '../../container.html')); +test('Filter should reset if the filter row editor text is cleared (T1257261)', async (t) => { + const dataGrid = new DataGrid('#container'); + const filterEditor = dataGrid.getFilterEditor(1, FilterTextBox); + const filterPanelText = dataGrid.getFilterPanel().getFilterText(); + + await t + // assert + .expect(filterPanelText.element.textContent) + .eql('[Text] Equals \'i\'') + // act + .click(filterEditor.input) + .pressKey('backspace') + .wait(100) // updateValueTimeout + // assert + .expect(filterPanelText.element.textContent) + .eql('Create Filter') + // act + .click(dataGrid.element) + // assert + .expect(filterPanelText.element.textContent) + .eql('Create Filter'); +}).before(async () => createWidget('dxDataGrid', { + dataSource: [ + { ID: 1, Text: 'Item 1' }, + { ID: 2, Text: '' }, + { ID: 3, Text: 'Item 3' }, + ], + keyExpr: 'ID', + showBorders: true, + remoteOperations: true, + headerFilter: { visible: true }, + filterRow: { visible: true }, + filterPanel: { visible: true }, + filterValue: ['Text', '=', 'i'], + columns: ['ID', { + dataField: 'Text', + selectedFilterOperation: '=', + }], + onEditorPreparing(e: any) { + e.updateValueTimeout = 100; + } +})); + test('Filter row\'s height should be adjusted by content (T1072609)', async (t) => { const dataGrid = new DataGrid('#container'); const { takeScreenshot, compareResults } = createScreenshotsComparer(t); From 5a689ef8b5412ee342e8346ce563ed90cbd0e122 Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Mon, 9 Dec 2024 13:19:55 +0800 Subject: [PATCH 06/10] lint --- e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts b/e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts index 1c4a985f1779..6fc220d919fb 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts @@ -49,7 +49,7 @@ test('Filter should reset if the filter row editor text is cleared (T1257261)', }], onEditorPreparing(e: any) { e.updateValueTimeout = 100; - } + }, })); test('Filter row\'s height should be adjusted by content (T1072609)', async (t) => { From 1173aedff38ccc48b6220c4c1e04928eb726556a Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Mon, 9 Dec 2024 14:18:10 +0800 Subject: [PATCH 07/10] fix --- .../js/ui/shared/ui.editor_factory_mixin.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js b/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js index ee54a4e11b54..a7841e265a46 100644 --- a/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js +++ b/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js @@ -49,18 +49,23 @@ const getTextEditorConfig = function(options) { onValueChanged: function(e) { const needDelayedUpdate = options.parentType === 'filterRow' || options.parentType === 'searchPanel'; - const notChangedProgrammatically = isDefined(e.event); + const isInputOrKeyUpEvent = e.event && (e.event.type === 'input' || e.event.type === 'keyup'); const updateValue = function(newValue, notFireEvent) { options && options.setValue(newValue, notFireEvent); }; clearTimeout(data.valueChangeTimeout); - if(notChangedProgrammatically && needDelayedUpdate) { - sharedData.valueChangeTimeout = data.valueChangeTimeout = setTimeout(function() { - const value = e.value === '' ? null : e.value; - updateValue(value, data.valueChangeTimeout !== sharedData.valueChangeTimeout); - }, isDefined(options.updateValueTimeout) ? options.updateValueTimeout : 0); + if(isDefined(e.event)) { + const newValue = e.value === '' ? null : e.value; + + if(isInputOrKeyUpEvent && needDelayedUpdate) { + sharedData.valueChangeTimeout = data.valueChangeTimeout = setTimeout(function() { + updateValue(newValue, data.valueChangeTimeout !== sharedData.valueChangeTimeout); + }, isDefined(options.updateValueTimeout) ? options.updateValueTimeout : 0); + } else { + updateValue(newValue); + } } else { updateValue(e.value); } From 568be08bf2f200ae40d8185bc93e6470769f234f Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Thu, 12 Dec 2024 18:30:09 +0800 Subject: [PATCH 08/10] reverse fix --- .../grids/grid_core/filter/m_filter_row.ts | 2 +- .../js/ui/shared/ui.editor_factory_mixin.js | 20 +++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts b/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts index 91d80a3cb6e1..496779c3de95 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts @@ -162,7 +162,7 @@ const normalizeFilterValue = function (that, filterValue, column, $editorContain }; const updateFilterValue = function (that, options) { - const { value } = options; + const value = options.value === '' ? null : options.value; const $editorContainer = options.container; const column = that._columnsController.columnOption(options.column.index); const filterValue = getFilterValue(that, column.index, $editorContainer); diff --git a/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js b/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js index a7841e265a46..e2f693daa68c 100644 --- a/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js +++ b/packages/devextreme/js/ui/shared/ui.editor_factory_mixin.js @@ -50,24 +50,18 @@ const getTextEditorConfig = function(options) { const needDelayedUpdate = options.parentType === 'filterRow' || options.parentType === 'searchPanel'; const isInputOrKeyUpEvent = e.event && (e.event.type === 'input' || e.event.type === 'keyup'); - const updateValue = function(newValue, notFireEvent) { - options && options.setValue(newValue, notFireEvent); + const updateValue = function(e, notFireEvent) { + options && options.setValue(e.value, notFireEvent); }; clearTimeout(data.valueChangeTimeout); - if(isDefined(e.event)) { - const newValue = e.value === '' ? null : e.value; - - if(isInputOrKeyUpEvent && needDelayedUpdate) { - sharedData.valueChangeTimeout = data.valueChangeTimeout = setTimeout(function() { - updateValue(newValue, data.valueChangeTimeout !== sharedData.valueChangeTimeout); - }, isDefined(options.updateValueTimeout) ? options.updateValueTimeout : 0); - } else { - updateValue(newValue); - } + if(isInputOrKeyUpEvent && needDelayedUpdate) { + sharedData.valueChangeTimeout = data.valueChangeTimeout = setTimeout(function() { + updateValue(e, data.valueChangeTimeout !== sharedData.valueChangeTimeout); + }, isDefined(options.updateValueTimeout) ? options.updateValueTimeout : 0); } else { - updateValue(e.value); + updateValue(e); } }, onKeyDown: function(e) { From 3bf6c5c4e0ef57b2f92358336f1d293d8d05fa13 Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Thu, 12 Dec 2024 19:51:18 +0800 Subject: [PATCH 09/10] new fix --- .../__internal/grids/grid_core/filter/m_filter_sync.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_sync.ts b/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_sync.ts index 48df0b766237..b42da82860c0 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_sync.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_sync.ts @@ -122,9 +122,13 @@ const updateFilterRowCondition = function (columnsController, column, condition) const filterValue = condition?.[2]; const filterOperations = column.filterOperations || column.defaultFilterOperations; - if ((!filterOperations || filterOperations.indexOf(selectedFilterOperation) >= 0 || selectedFilterOperation === column.defaultFilterOperation) - && FILTER_ROW_OPERATIONS.includes(selectedFilterOperation) && filterValue !== null) { - if (selectedFilterOperation === column.defaultFilterOperation && !isDefined(column.selectedFilterOperation)) { + const selectedOperationExists = filterOperations.indexOf(selectedFilterOperation) >= 0; + const defaultOperationSelected = selectedFilterOperation === column.defaultFilterOperation; + const builtInOperationSelected = FILTER_ROW_OPERATIONS.includes(selectedFilterOperation); + const filterValueNotNullOrEmpty = filterValue !== null && filterValue !== ''; + + if ((!filterOperations || selectedOperationExists || defaultOperationSelected) && builtInOperationSelected && filterValueNotNullOrEmpty) { + if (defaultOperationSelected && !isDefined(column.selectedFilterOperation)) { selectedFilterOperation = column.selectedFilterOperation; } filterRowOptions = { From 986d9bc5c9ea954c377e60175de3e239dcf1a23b Mon Sep 17 00:00:00 2001 From: Mark Allen Ramirez Date: Thu, 12 Dec 2024 20:21:23 +0800 Subject: [PATCH 10/10] fix --- .../js/__internal/grids/grid_core/filter/m_filter_sync.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_sync.ts b/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_sync.ts index b42da82860c0..7389ab42f2d0 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_sync.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_sync.ts @@ -122,12 +122,12 @@ const updateFilterRowCondition = function (columnsController, column, condition) const filterValue = condition?.[2]; const filterOperations = column.filterOperations || column.defaultFilterOperations; - const selectedOperationExists = filterOperations.indexOf(selectedFilterOperation) >= 0; + const selectedOperationExists = !filterOperations || filterOperations.indexOf(selectedFilterOperation) >= 0; const defaultOperationSelected = selectedFilterOperation === column.defaultFilterOperation; const builtInOperationSelected = FILTER_ROW_OPERATIONS.includes(selectedFilterOperation); const filterValueNotNullOrEmpty = filterValue !== null && filterValue !== ''; - if ((!filterOperations || selectedOperationExists || defaultOperationSelected) && builtInOperationSelected && filterValueNotNullOrEmpty) { + if ((selectedOperationExists || defaultOperationSelected) && builtInOperationSelected && filterValueNotNullOrEmpty) { if (defaultOperationSelected && !isDefined(column.selectedFilterOperation)) { selectedFilterOperation = column.selectedFilterOperation; }