fix(plugin-search-react): reset page cursor when page limit changes
Signed-off-by: Gabriel Testault <gabriel.testault@goto.com>
This commit is contained in:
committed by
Renan Mendes Carvalho
parent
6ca4123ce6
commit
f9114941c9
@@ -191,12 +191,20 @@ export const SearchPagination = (props: SearchPaginationProps) => {
|
||||
const { pageLimit, setPageLimit, pageCursor, setPageCursor, fetchNextPage } =
|
||||
useSearch();
|
||||
|
||||
const handlePageLimitChange = useCallback(
|
||||
(newPageLimit: number) => {
|
||||
setPageLimit(newPageLimit);
|
||||
setPageCursor(undefined);
|
||||
},
|
||||
[setPageLimit, setPageCursor],
|
||||
);
|
||||
|
||||
return (
|
||||
<SearchPaginationBase
|
||||
{...props}
|
||||
hasNextPage={!!fetchNextPage}
|
||||
limit={pageLimit}
|
||||
onLimitChange={setPageLimit}
|
||||
onLimitChange={handlePageLimitChange}
|
||||
cursor={pageCursor}
|
||||
onCursorChange={setPageCursor}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user