Skip to content

Commit

Permalink
fix: reset isSearch flag when filters are empty (#3978)
Browse files Browse the repository at this point in the history
  • Loading branch information
leopuleo authored Mar 6, 2024
1 parent 1383e9e commit 044028b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/app-aco/src/contexts/acoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,15 @@ export const AcoListProvider = ({ children, ...props }: AcoListProviderProps) =>
setState({ searchQuery: query, after: undefined });
},
setFilters(data) {
setState({ filters: data, after: undefined });
// Create filters object excluding entries with `undefined` values
const filters = Object.fromEntries(
Object.entries(data).filter(([, value]) => value !== undefined)
);

setState({
filters: Object.keys(filters).length ? filters : undefined,
after: undefined
});
},
setListSort(sort: ListSearchRecordsSort) {
setState({ listSort: sort, after: undefined });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,15 @@ export const FileManagerViewProvider = ({ children, ...props }: FileManagerViewP
}));
},
setFilters(data) {
// Create filters object excluding entries with `undefined` values
const filters = Object.fromEntries(
Object.entries(data).filter(([, value]) => value !== undefined)
);

setState(state => ({
...state,
selected: [],
filters: data,
filters: Object.keys(filters).length ? filters : undefined,
selection: {}
}));
},
Expand Down

0 comments on commit 044028b

Please sign in to comment.