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
11 changes: 4 additions & 7 deletions packages/react-core/src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ export const Pagination: React.FunctionComponent<PaginationProps> = ({
ofWord: 'of'
},
firstPage = 1,
page: pageProp = 0,
offset = 0,
page: pageProp = 1,
offset = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other props in Pagination also have a default value of null like itemsStart = null, itemsEnd = null,
and usually its not recomended to set values to undefined

isLastFullPageShown = false,
itemsStart = null,
itemsEnd = null,
Expand Down Expand Up @@ -245,11 +245,8 @@ export const Pagination: React.FunctionComponent<PaginationProps> = ({
const dropDirection = dropDirectionProp || (variant === 'bottom' && !isStatic ? 'up' : 'down');

let page = pageProp;
if (!page && offset) {
page = Math.ceil(offset / perPage);
}
if (page === 0 && !itemCount) {
page = 1;
if (offset !== null) {
page = Math.max(Math.ceil(offset / perPage), 1);
}

const lastPage = getLastPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ exports[`Pagination component render custom pagination toggle 1`] = `
<div
class="pf-v5-c-pagination__total-items"
>
-9 - 10 - 40 -
1 - 10 - 40 -
</div>
<div>
<button
Expand All @@ -1172,7 +1172,7 @@ exports[`Pagination component render custom pagination toggle 1`] = `
<span
class="pf-v5-c-menu-toggle__text"
>
-9 - 10 - 40 -
1 - 10 - 40 -
</span>
<span
class="pf-v5-c-menu-toggle__controls"
Expand Down Expand Up @@ -1341,7 +1341,7 @@ exports[`Pagination component render custom perPageOptions 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand All @@ -1361,7 +1361,7 @@ exports[`Pagination component render custom perPageOptions 1`] = `
class="pf-v5-c-menu-toggle__text"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -1536,7 +1536,7 @@ exports[`Pagination component render custom start end 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -1729,7 +1729,7 @@ exports[`Pagination component render empty per page options 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -2078,7 +2078,7 @@ exports[`Pagination component render limited number of pages 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-19 - 20
1 - 20
</b>
of
<b>
Expand All @@ -2098,7 +2098,7 @@ exports[`Pagination component render limited number of pages 1`] = `
class="pf-v5-c-menu-toggle__text"
>
<b>
-19 - 20
1 - 20
</b>
of
<b>
Expand Down Expand Up @@ -2284,7 +2284,7 @@ exports[`Pagination component render should render correctly bottom 1`] = `
class="pf-v5-c-menu-toggle__text"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -2467,7 +2467,7 @@ exports[`Pagination component render should render correctly bottom sticky 1`] =
class="pf-v5-c-menu-toggle__text"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -2642,7 +2642,7 @@ exports[`Pagination component render should render correctly compact 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand All @@ -2662,7 +2662,7 @@ exports[`Pagination component render should render correctly compact 1`] = `
class="pf-v5-c-menu-toggle__text"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -2767,7 +2767,7 @@ exports[`Pagination component render should render correctly disabled 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand All @@ -2788,7 +2788,7 @@ exports[`Pagination component render should render correctly disabled 1`] = `
class="pf-v5-c-menu-toggle__text"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -2966,7 +2966,7 @@ exports[`Pagination component render should render correctly sticky 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand All @@ -2986,7 +2986,7 @@ exports[`Pagination component render should render correctly sticky 1`] = `
class="pf-v5-c-menu-toggle__text"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -3161,7 +3161,7 @@ exports[`Pagination component render should render correctly top 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand All @@ -3181,7 +3181,7 @@ exports[`Pagination component render should render correctly top 1`] = `
class="pf-v5-c-menu-toggle__text"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -3356,7 +3356,7 @@ exports[`Pagination component render titles 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand All @@ -3376,7 +3376,7 @@ exports[`Pagination component render titles 1`] = `
class="pf-v5-c-menu-toggle__text"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down Expand Up @@ -3551,7 +3551,7 @@ exports[`Pagination component render up drop direction 1`] = `
class="pf-v5-c-pagination__total-items"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand All @@ -3571,7 +3571,7 @@ exports[`Pagination component render up drop direction 1`] = `
class="pf-v5-c-menu-toggle__text"
>
<b>
-9 - 10
1 - 10
</b>
of
<b>
Expand Down