0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 14:22:52 +00:00

keep current page number within existing page range

Make it so that if a user enters a page number higher than the total page count, it jumps them to last page.  if lower than 1, it jumps them to first page.
This commit is contained in:
Gazook89
2024-08-19 23:40:21 -05:00
parent 2cf73698e8
commit f5ee55d0ca
2 changed files with 4 additions and 3 deletions

View File

@@ -26,8 +26,8 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
};
const handlePageChange = (page)=>{
setPageInput((page));
}
setPageInput(page);
};
return (
<div className='toolBar'>
@@ -88,6 +88,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
onChange={(e)=>{
handlePageChange(e.target.value == false ? e.target.value : parseInt(e.target.value));}}
onBlur={()=>onPageChange(pageInput)}
onKeyDown={(e)=>{e.key == 'Enter' ? onPageChange(pageInput) : null;}}
/>
<span id='page-count'>/ {totalPages}</span>