catalog-react: reset filters on cursor change

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2023-11-10 13:39:53 +01:00
parent acc928f0ad
commit 6f47804063
@@ -296,6 +296,12 @@ export const EntityListProvider = <EntityFilters extends DefaultEntityFilters>(
| Partial<EntityFilter>
| ((prevFilters: EntityFilters) => Partial<EntityFilters>),
) => {
// changing filters will affect pagination, so we need to reset
// the cursor and start from the first page.
// TODO(vinzscam): this is currently causing issues at page reload
// where the state is not kept. Unfortunately we need to rething
// the way filters work in order to fix this.
setCursor(undefined);
setRequestedFilters(prevFilters => {
const newFilters =
typeof update === 'function' ? update(prevFilters) : update;