Skip to content

Commit

Permalink
Fix primefaces#3430/primefaces#2996: Datatable global filter has old …
Browse files Browse the repository at this point in the history
…value
  • Loading branch information
melloware committed Oct 7, 2022
1 parent fba792c commit 196d506
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/lib/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,10 +976,10 @@ export const DataTable = React.forwardRef((props, ref) => {
setD_filtersState(filters);
};

const onFilterApply = () => {
const onFilterApply = (filtersToApply) => {
clearTimeout(filterTimeout.current);
filterTimeout.current = setTimeout(() => {
let filters = cloneFilters(d_filtersState);
const filters = cloneFilters(filtersToApply || d_filtersState);

if (props.onFilter) {
props.onFilter(createEvent({ filters }));
Expand Down Expand Up @@ -1130,7 +1130,7 @@ export const DataTable = React.forwardRef((props, ref) => {
props.filterDisplay === 'menu' && meta && meta.operator ? (filters[field].constraints[index] = constraint) : (filters[field] = constraint);

setD_filtersState(filters);
onFilterApply();
onFilterApply(filters);
};

const reset = () => {
Expand Down Expand Up @@ -1333,7 +1333,7 @@ export const DataTable = React.forwardRef((props, ref) => {

useUpdateEffect(() => {
if (props.globalFilter) {
filter(props.globalFilter, 'global', 'contains');
filter(props.globalFilter, 'global', props.globalFilterMatchMode);
}
}, [props.globalFilter]);

Expand Down

0 comments on commit 196d506

Please sign in to comment.