diff --git a/__tests__/components/Pagination.test.jsx b/__tests__/components/Pagination.test.jsx
index b2ca6727e8..552642665c 100644
--- a/__tests__/components/Pagination.test.jsx
+++ b/__tests__/components/Pagination.test.jsx
@@ -119,6 +119,63 @@ describe('', () => {
pageSizeDropdownItems.at(1).simulate('click');
});
+ test('itemCount displays correctly', () => {
+ const onSetPage = jest.fn();
+
+ pagination = mount(
+
+
+
+ );
+ const itemCount = pagination.find('.awx-pagination__item-count');
+ expect(itemCount.text()).toEqual('Items 1 – 5 of 7');
+ });
+
+ test('itemCount matching pageSize displays correctly', () => {
+ const onSetPage = jest.fn();
+
+ pagination = mount(
+
+
+
+ );
+ const itemCount = pagination.find('.awx-pagination__item-count');
+ expect(itemCount.text()).toEqual('Items 1 – 5 of 5');
+ });
+
+ test('itemCount less than pageSize displays correctly', () => {
+ const onSetPage = jest.fn();
+
+ pagination = mount(
+
+
+
+ );
+ const itemCount = pagination.find('.awx-pagination__item-count');
+ expect(itemCount.text()).toEqual('Items 1 – 3 of 3');
+ });
+
test('submit a new page by typing in input works', () => {
const textInputSelector = '.awx-pagination__page-input.pf-c-form-control';
const submitFormSelector = '.awx-pagination__page-input-form';
diff --git a/src/components/Pagination/Pagination.jsx b/src/components/Pagination/Pagination.jsx
index 98a03b8e8c..a3eba1ca3e 100644
--- a/src/components/Pagination/Pagination.jsx
+++ b/src/components/Pagination/Pagination.jsx
@@ -116,7 +116,12 @@ class Pagination extends Component {
const isOnFirst = page === 1;
const isOnLast = page === pageCount;
- const itemCount = isOnLast ? count % page_size : page_size;
+ let itemCount;
+ if (!isOnLast || count === page_size) {
+ itemCount = page_size;
+ } else {
+ itemCount = count % page_size;
+ }
const itemMin = ((page - 1) * page_size) + 1;
const itemMax = itemMin + itemCount - 1;
@@ -154,7 +159,7 @@ class Pagination extends Component {
)}
- {`Items ${itemMin} - ${itemMax} of ${count}`}
+ {`Items ${itemMin} – ${itemMax} of ${count}`}
{pageCount !== 1 && (