From eb684bb59dbd79c2c781ff3e64e6b292c13be218 Mon Sep 17 00:00:00 2001 From: MariaAga Date: Thu, 11 Jul 2024 16:52:37 +0100 Subject: [PATCH] Fixes #37644 - Pagination doesnt update between react pages --- .../react_app/components/Pagination/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/webpack/assets/javascripts/react_app/components/Pagination/index.js b/webpack/assets/javascripts/react_app/components/Pagination/index.js index 796767424fb..12dbf5df166 100644 --- a/webpack/assets/javascripts/react_app/components/Pagination/index.js +++ b/webpack/assets/javascripts/react_app/components/Pagination/index.js @@ -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 = { @@ -105,6 +107,7 @@ const Pagination = ({ const cx = classNames('tfm-pagination', className, { 'no-side-padding': noSidePadding, }); + return (