Skip to content

Commit

Permalink
feat: add keyboard action
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas.J.Han <[email protected]>
  • Loading branch information
lukasjhan committed Aug 15, 2024
1 parent 2c9375e commit 9faf50d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/core/lib/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ export const Pagination: React.FC<PaginationProps> = ({
</button>
);

const inputPageNumber = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === ' ' || e.key === 'Enter') {
e.preventDefault();
onPageChange(inputPage);
return;
}
};

return (
<nav
aria-label={'페이지 네비게이션'}
Expand All @@ -206,6 +214,7 @@ export const Pagination: React.FC<PaginationProps> = ({
type="number"
value={inputPage}
onChange={(e) => setInputPage(parseInt(e.target.value, 10))}
onKeyDown={inputPageNumber}
min={1}
max={totalPages}
className="w-14 px-2 py-1 border border-gray-50 rounded-2 focus:outline-none focus:ring-2 focus:ring-primary-50 text-right"
Expand Down

0 comments on commit 9faf50d

Please sign in to comment.