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 docs/examples/simple.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ import React from 'react';
import Pagination from 'rc-pagination';
import '../../assets/index.less';

export default () => <Pagination simple defaultCurrent={1} total={50} />;
export default () => (
<>
<Pagination simple defaultCurrent={1} total={50} />
<br />
<Pagination
simple
defaultCurrent={1}
total={50}
showTotal={(total) => `Total ${total} items`}
/>
</>
);
24 changes: 11 additions & 13 deletions src/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,15 @@ class Pagination extends React.Component {
},
{},
);

const totalText = showTotal && (
<li className={`${prefixCls}-total-text`}>
{showTotal(total, [
total === 0 ? 0 : (current - 1) * pageSize + 1,
current * pageSize > total ? total : current * pageSize,
])}
</li>
);

if (simple) {
if (goButton) {
Expand Down Expand Up @@ -467,6 +476,7 @@ class Pagination extends React.Component {
ref={this.savePaginationNode}
{...dataOrAriaAttributeProps}
>
{totalText}
<li
title={showTitle ? locale.prev_page : null}
onClick={this.prev}
Expand Down Expand Up @@ -661,19 +671,7 @@ class Pagination extends React.Component {
pagerList.push(lastPager);
}
}

let totalText = null;

if (showTotal) {
totalText = (
<li className={`${prefixCls}-total-text`}>
{showTotal(total, [
total === 0 ? 0 : (current - 1) * pageSize + 1,
current * pageSize > total ? total : current * pageSize,
])}
</li>
);
}

const prevDisabled = !this.hasPrev() || !allPages;
const nextDisabled = !this.hasNext() || !allPages;
return (
Expand Down