Skip to content

fix: click some page & prev btn #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 5, 2021
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
12 changes: 6 additions & 6 deletions src/Options.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ class Options extends React.Component {
if (goButton || goInputText === '') {
return;
}
this.setState({
goInputText: '',
});
if (
e.relatedTarget &&
(e.relatedTarget.className.indexOf(`${rootPrefixCls}-prev`) >= 0 ||
e.relatedTarget.className.indexOf(`${rootPrefixCls}-next`) >= 0)
(e.relatedTarget.className.indexOf(`${rootPrefixCls}-item-link`) >= 0 ||
e.relatedTarget.className.indexOf(`${rootPrefixCls}-item`) >= 0)
) {
return;
}
this.setState({
goInputText: '',
});
quickGo(this.getValidValue());
};

Expand Down Expand Up @@ -122,7 +122,7 @@ class Options extends React.Component {
dropdownMatchSelectWidth={false}
value={(pageSize || pageSizeOptions[0]).toString()}
onChange={this.changeSize}
getPopupContainer={triggerNode => triggerNode.parentNode}
getPopupContainer={(triggerNode) => triggerNode.parentNode}
>
{options}
</Select>
Expand Down
28 changes: 28 additions & 0 deletions tests/jumper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ describe('Pagination with jumper', () => {
expect(wrapper.state().current).toBe(10);
expect(onChange).not.toBeCalled();
});

it('should not jumper when click pre/next button', () => {
const quickJumper = wrapper.find('.rc-pagination-options-quick-jumper');
const input = quickJumper.find('input');
input.simulate('change', { target: { value: '13' } });
const mockEvent = {
relatedTarget: {
className: 'rc-pagination-item-link',
},
};
input.simulate('blur', mockEvent);
expect(input.instance().value).toBe('');
expect(onChange).not.toBeCalled();
});

it('should not jumper when click page', () => {
const quickJumper = wrapper.find('.rc-pagination-options-quick-jumper');
const input = quickJumper.find('input');
input.simulate('change', { target: { value: '13' } });
const mockEvent = {
relatedTarget: {
className: 'rc-pagination-item',
},
};
input.simulate('blur', mockEvent);
expect(input.instance().value).toBe('');
expect(onChange).not.toBeCalled();
});
});

describe('simple quick jumper', () => {
Expand Down