Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const Options: React.FC<OptionsProps> = (props) => {
{locale.jump_to}
<input
disabled={disabled}
type="text"
type="number"
value={goInputText}
onChange={handleChange}
onKeyUp={go}
Expand Down
12 changes: 6 additions & 6 deletions tests/__snapshots__/demo.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ exports[`Example jumper 1`] = `
跳至
<input
aria-label="页"
type="text"
type="number"
value=""
/>
Expand Down Expand Up @@ -1874,7 +1874,7 @@ exports[`Example jumper 1`] = `
<input
aria-label="页"
disabled=""
type="text"
type="number"
value=""
/>
Expand Down Expand Up @@ -2234,7 +2234,7 @@ exports[`Example jumperWithGoButton 1`] = `
跳至
<input
aria-label="页"
type="text"
type="number"
value=""
/>
Expand Down Expand Up @@ -2303,7 +2303,7 @@ exports[`Example jumperWithGoButton 1`] = `
跳至
<input
aria-label="页"
type="text"
type="number"
value=""
/>
Expand Down Expand Up @@ -2776,7 +2776,7 @@ exports[`Example locale 1`] = `
Go to
<input
aria-label="Page"
type="text"
type="number"
value=""
/>
Page
Expand Down Expand Up @@ -4020,7 +4020,7 @@ exports[`Example simple 1`] = `
跳至
<input
aria-label="页"
type="text"
type="number"
value=""
/>
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/options.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ exports[`Options should render correctly 1`] = `
跳至
<input
aria-label="页"
type="text"
type="number"
value=""
/>
Expand Down
6 changes: 3 additions & 3 deletions tests/__snapshots__/simple.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`simple Pagination props: showQuickJumper should render normally quick-j
跳至
<input
aria-label="页"
type="text"
type="number"
value=""
/>
Expand All @@ -21,7 +21,7 @@ exports[`simple Pagination props: showQuickJumper should render normally quick-j
跳至
<input
aria-label="页"
type="text"
type="number"
value=""
/>
Expand Down Expand Up @@ -49,7 +49,7 @@ exports[`simple Pagination props: showQuickJumper should render normally quick-j
跳至
<input
aria-label="页"
type="text"
type="number"
value=""
/>
Expand Down
44 changes: 42 additions & 2 deletions tests/jumper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Pagination with jumper', () => {
relatedTarget.className = 'rc-pagination-item-link';
fireEvent.blur(input, { relatedTarget });

expect(input).toHaveValue('');
expect(input).toHaveValue(null);
expect(onChange).not.toHaveBeenCalled();
});

Expand All @@ -64,7 +64,7 @@ describe('Pagination with jumper', () => {
relatedTarget.className = 'rc-pagination-item';
fireEvent.blur(input, { relatedTarget });

expect(input).toHaveValue('');
expect(input).toHaveValue(null);
expect(onChange).not.toHaveBeenCalled();
});

Expand Down Expand Up @@ -271,3 +271,43 @@ describe('simple quick jumper', () => {
).toBeFalsy();
});
});

describe('inputType number', () => {
it('should accept only number', () => {
const onChange = jest.fn();
const { container } = render(
<Pagination
onChange={onChange}
defaultCurrent={1}
total={95}
pageSize={10}
showQuickJumper={{ inputType: 'number' }}
/>,
);
const quickJumper = container.querySelector(
'.rc-pagination-options-quick-jumper',
);
const input = quickJumper.querySelector('input');
fireEvent.change(input, { target: { value: '42' } });
expect(input.value).toBe('42');
});

it('should not accept non-number', () => {
const onChange = jest.fn();
const { container } = render(
<Pagination
onChange={onChange}
defaultCurrent={1}
total={95}
pageSize={10}
showQuickJumper={{ inputType: 'number' }}
/>,
);
const quickJumper = container.querySelector(
'.rc-pagination-options-quick-jumper',
);
const input = quickJumper.querySelector('input');
fireEvent.change(input, { target: { value: 'abc' } });
expect(input.value).toBe('');
});
});