diff --git a/ui/v2.5/src/components/List/Pagination.tsx b/ui/v2.5/src/components/List/Pagination.tsx index 3db7d2f82..ab1511882 100644 --- a/ui/v2.5/src/components/List/Pagination.tsx +++ b/ui/v2.5/src/components/List/Pagination.tsx @@ -19,16 +19,16 @@ const PageCount: React.FC<{ onChangePage: (page: number) => void; }> = ({ totalPages, currentPage, onChangePage }) => { const intl = useIntl(); - const currentPageCtrl = useRef(null); - const [pageInput, pageFocus] = useFocus(); - const [showSelectPage, setShowSelectPage] = useState(false); useEffect(() => { if (showSelectPage) { - pageFocus(); + // delaying the focus to the next execution loop so that rendering takes place first and stops the page from resetting. + setTimeout(() => { + pageFocus(); + }, 0); } }, [showSelectPage, pageFocus]); @@ -105,7 +105,7 @@ const PageCount: React.FC<{ className="text-input" ref={pageInput} defaultValue={currentPage} - onKeyPress={(e: React.KeyboardEvent) => { + onKeyDown={(e: React.KeyboardEvent) => { if (e.key === "Enter") { onCustomChangePage(); e.preventDefault(); @@ -152,7 +152,6 @@ export const Pagination: React.FC = ({ onChangePage, }) => { const intl = useIntl(); - const totalPages = useMemo( () => Math.ceil(totalItems / itemsPerPage), [totalItems, itemsPerPage]