From 2b8202af728d994a3b80beff1f3a3ddf47c804d0 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Wed, 9 Aug 2023 18:50:27 +0200 Subject: [PATCH] fix pagination (#22287) fixes: #21949 --- js/apps/admin-ui/src/groups/components/GroupTree.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/apps/admin-ui/src/groups/components/GroupTree.tsx b/js/apps/admin-ui/src/groups/components/GroupTree.tsx index 63644e4771..b8f9bab8a7 100644 --- a/js/apps/admin-ui/src/groups/components/GroupTree.tsx +++ b/js/apps/admin-ui/src/groups/components/GroupTree.tsx @@ -13,7 +13,7 @@ import { TreeView, TreeViewDataItem, } from "@patternfly/react-core"; -import { useState } from "react"; +import { useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; @@ -130,6 +130,8 @@ export const GroupTree = ({ const [search, setSearch] = useState(""); const [max, setMax] = useState(20); const [first, setFirst] = useState(0); + const prefFirst = useRef(0); + const prefMax = useRef(20); const [count, setCount] = useState(0); const [exact, setExact] = useState(false); const [activeItem, setActiveItem] = useState(); @@ -220,7 +222,7 @@ export const GroupTree = ({ ]; } setGroups(groups); - if (search) { + if (search || prefFirst.current !== first || prefMax.current !== max) { setData(groups.map((g) => mapGroup(g, refresh))); } else { setData( @@ -232,6 +234,8 @@ export const GroupTree = ({ ); } setCount(count); + prefFirst.current = first; + prefMax.current = max; }, [key, first, firstSub, max, search, exact, activeItem], );