From 6f478040633ea0022c42b89a798e7ea9512d51c3 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Fri, 10 Nov 2023 13:39:53 +0100 Subject: [PATCH] catalog-react: reset filters on cursor change Signed-off-by: Vincenzo Scamporlino --- plugins/catalog-react/src/hooks/useEntityListProvider.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx index ef1673d69a..2e187789fd 100644 --- a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx +++ b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx @@ -296,6 +296,12 @@ export const EntityListProvider = ( | Partial | ((prevFilters: EntityFilters) => Partial), ) => { + // 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;