diff --git a/src/ui/component/common/paginate.jsx b/src/ui/component/common/paginate.jsx index da07d6d8a..3bd78fc85 100644 --- a/src/ui/component/common/paginate.jsx +++ b/src/ui/component/common/paginate.jsx @@ -5,7 +5,6 @@ import { Form, FormField } from 'component/common/form'; import ReactPaginate from 'react-paginate'; const PAGINATE_PARAM = 'page'; -const ENTER_KEY_CODE = 13; type Props = { loading: boolean, @@ -18,6 +17,7 @@ type Props = { function Paginate(props: Props) { const { totalPages = 1, loading, location, history, onPageChange } = props; const { search } = location; + const [textValue, setTextValue] = React.useState(''); const urlParams = new URLSearchParams(search); const currentPage = Number(urlParams.get(PAGINATE_PARAM)) || 1; @@ -31,11 +31,9 @@ function Paginate(props: Props) { } } - function handlePaginateKeyUp(e: SyntheticKeyboardEvent<*>) { - const newPage = Number(e.currentTarget.value); - const isEnterKey = e.keyCode === ENTER_KEY_CODE; - - if (newPage && isEnterKey && newPage > 0 && newPage <= totalPages) { + function handlePaginateKeyUp() { + const newPage = Number(textValue); + if (newPage && newPage > 0 && newPage <= totalPages) { handleChangePage(newPage); } } @@ -43,7 +41,7 @@ function Paginate(props: Props) { return ( // Hide the paginate controls if we are loading or there is only one page // It should still be rendered to trigger the onPageChange callback -