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
19 changes: 12 additions & 7 deletions src/Pager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@
import React from 'react';
import classNames from 'classnames';

const Pager = props => {
const Pager = (props) => {
const prefixCls = `${props.rootPrefixCls}-item`;
const cls = classNames(prefixCls, `${prefixCls}-${props.page}`, {
[`${prefixCls}-active`]: props.active,
[props.className]: !!props.className,
[`${prefixCls}-disabled`]: !props.page,
});
const cls = classNames(
prefixCls,
`${prefixCls}-${props.page}`,
{
[`${prefixCls}-active`]: props.active,
[props.className]: !!props.className,
[`${prefixCls}-disabled`]: !props.page,
},
props.className,
);

const handleClick = () => {
props.onClick(props.page);
};

const handleKeyPress = e => {
const handleKeyPress = (e) => {
props.onKeyPress(e, props.onClick, props.page);
};

Expand Down
4 changes: 2 additions & 2 deletions src/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ class Pagination extends React.Component {
<Pager
{...pagerProps}
key="noPager"
page={allPages}
className={`${prefixCls}-disabled`}
page={1}
className={`${prefixCls}-item-disabled`}
/>,
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,10 @@ describe('current value on onShowSizeChange when total is 0', () => {
);
});

it('when total is 0, pager should show and disabled', () => {
it('when total is 0, pager should show `1` and being disabled', () => {
const itemButton = wrapper.find('.rc-pagination-item');
expect(itemButton.hasClass('rc-pagination-item-disabled')).toBe(true);
expect(itemButton.text()).toBe('1');
});

it('when total is 0, `from` and `to` should be 0', () => {
Expand Down