Skip to content

Commit

Permalink
Fixes #37644 - Pagination doesnt update between react pages
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga authored and jeremylenz committed Jul 25, 2024
1 parent 175b5f2 commit eb684bb
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ const Pagination = ({
let nextPage = propsPage;
let nextPerPage = propsPerPage;
if (updateParamsByUrl) {
if (search !== undefined) {
if (search !== undefined && search.length) {
const params = new URLSearchParams(search);
nextPage = Number(params.get('page'));
nextPerPage = Number(params.get('per_page'));
nextPage = Number(params.get('page') || getURIpage());
nextPerPage = Number(params.get('per_page') || getURIperPage());
} else {
nextPage = getURIpage();
nextPerPage = getURIperPage();
}
}
setPerPage(current => nextPerPage || current || settingsPerPage);
setPage(current => nextPage || current);
setPerPage(
current => nextPerPage || propsPerPage || current || settingsPerPage
);
setPage(current => nextPage || propsPage || current);
}, [search, propsPage, propsPerPage, settingsPerPage, updateParamsByUrl]);

const paginationTitles = {
Expand Down Expand Up @@ -105,6 +107,7 @@ const Pagination = ({
const cx = classNames('tfm-pagination', className, {
'no-side-padding': noSidePadding,
});

return (
<PF4Pagination
titles={paginationTitles}
Expand Down

0 comments on commit eb684bb

Please sign in to comment.