Skip to content

Commit

Permalink
fix(DataTable): Don't mix controlled and uncontrolled filter (#7104)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Et7f3 authored Sep 3, 2024
1 parent 708afc0 commit cfe5b03
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/lib/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit cfe5b03

Please sign in to comment.