Skip to content
Merged
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
13 changes: 12 additions & 1 deletion src/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ class Pagination extends React.Component {

isValid = (page) => {
const { total } = this.props;
return isInteger(page) && page !== this.state.current && isInteger(total) && total > 0;
return (
isInteger(page) &&
page !== this.state.current &&
isInteger(total) &&
total > 0
);
};

shouldDisplayQuickJumper = () => {
Expand Down Expand Up @@ -206,6 +211,11 @@ class Pagination extends React.Component {
}
};

handleBlur = (e) => {
const value = this.getValidValue(e);
this.handleChange(value);
};

changePageSize = (size) => {
let { current } = this.state;
const newCurrent = calculatePage(size, this.state, this.props);
Expand Down Expand Up @@ -476,6 +486,7 @@ class Pagination extends React.Component {
onKeyDown={this.handleKeyDown}
onKeyUp={this.handleKeyUp}
onChange={this.handleKeyUp}
onBlur={this.handleBlur}
size="3"
/>
<span className={`${prefixCls}-slash`}>/</span>
Expand Down
12 changes: 12 additions & 0 deletions tests/simple.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ describe('simple Pagination', () => {
wrapper.unmount();
});

it('input change value will emit onChange when input blur', () => {
const onChange = jest.fn();
const component = mount(
<Pagination simple total={25} onChange={onChange} />,
);
const greaterCurrent = component.find('.rc-pagination-simple');
const input = greaterCurrent.find('input');
input.simulate('change', { target: { value: '2' } });
input.simulate('blur');
expect(onChange).toBeCalled();
});

it('default current page is 1', () => {
expect(wrapper.state().current).toBe(1);
});
Expand Down