Skip to content

Commit 44f5e65

Browse files
fix: restrict Pagination QuickJumper to numeric input only (#662)
1 parent 7ffdf47 commit 44f5e65

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Options.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ const Options: React.FC<OptionsProps> = (props) => {
6060
: (value: string | number) => `${value} ${locale.items_per_page}`;
6161

6262
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
63-
setGoInputText(e.target.value);
63+
const value = e.target.value;
64+
if (/^\d*$/.test(value)) {
65+
setGoInputText(value);
66+
}
6467
};
6568

6669
const handleBlur = (e: React.FocusEvent<HTMLInputElement, Element>) => {

tests/jumper.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ describe('Pagination with jumper', () => {
2929
expect(quickJumper).toBeTruthy();
3030
const input = quickJumper.querySelector('input');
3131
fireEvent.change(input, { target: { value: '-1' } });
32+
expect(input.value).toBe('');
33+
fireEvent.change(input, { target: { value: '1' } });
3234
fireEvent.keyUp(input, { key: 'Enter', keyCode: 13, which: 13 });
3335
expect($$('.rc-pagination-item-active')).toHaveTextContent('1');
3436
expect(onChange).toHaveBeenLastCalledWith(1, 10);

0 commit comments

Comments
 (0)