From cfe5b03418ae296fbdb25a42ddea4f9ed1e3815d Mon Sep 17 00:00:00 2001 From: Et7f3 Date: Tue, 3 Sep 2024 13:39:39 +0200 Subject: [PATCH] fix(DataTable): Don't mix controlled and uncontrolled filter (#7104) In a components where `props.filters` is not set because user rely on generated filter object: if a column filter is applied, a global filter is applied and then the global filter set to "" the `props.filter` is used (null) instead of the generated filter (object with only one column defined). The generated filter object before global filtering enter in action has no `global` key: so we revert this modifications. --- components/lib/datatable/DataTable.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/lib/datatable/DataTable.js b/components/lib/datatable/DataTable.js index 302479537f..c6ba016526 100644 --- a/components/lib/datatable/DataTable.js +++ b/components/lib/datatable/DataTable.js @@ -1503,7 +1503,12 @@ export const DataTable = React.forwardRef((inProps, ref) => { filter(props.globalFilter, 'global', props.globalFilterMatchMode); } else { // #3819 was filtering but now reset filter state - setFiltersState(props.filters); + if (d_filtersState["global"]) { + let filters = { ...d_filtersState }; + delete filters["global"]; + setD_filtersState(filters); + onFilterApply(filters); + } } }, [props.globalFilter, props.globalFilterMatchMode]);