Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37644 - Pagination doesnt update between react pages #10241

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 34 there's perPage. Why isn't that used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 34 is: const [perPage, setPerPage] = useState(propsPerPage || settingsPerPage);
and then later in this useeffect theres setPerPage(current => nextPerPage || current || settingsPerPage);

} 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
Loading