Skip to content

Commit

Permalink
fix(paginator): delete number 1 from input
Browse files Browse the repository at this point in the history
  • Loading branch information
malegreIndec committed Dec 20, 2023
1 parent 7756528 commit fe63628
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/Pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ const Pagination = ({
}
};

const handleBlur = () => {
if (Number.isNaN(search)) {
setSearch(1);
}
};

useEffect(() => {
setPages(getPagesRange(null, currentPage, totalPages) || []);
}, [totalPages]);
Expand Down Expand Up @@ -115,8 +121,10 @@ const Pagination = ({
min={1}
max={totalPages}
onChange={handleChangeInput}
value={!Number.isNaN(search) ? search : 1}
defaultValue={1}
value={!Number.isNaN(search) ? search : undefined}
onKeyDown={handleKeyDown}
onBlur={handleBlur}
>
<NumberInputField p="0 10px" data-testid="input"/>
</NumberInput>
Expand Down

0 comments on commit fe63628

Please sign in to comment.