When boundaryCount is set to zero, Pagination:
Pagination should not ignore the siblingCount value when boundaryCount is set to zero.
https://codesandbox.io/s/quirky-chebyshev-h25pc
Steps:
I would like to have a Pagination with the previous, current e next page numbers.
On chrome and firefox. I think the problem is not about the environment in this case.
| Tech | Version |
| ----------- | ------- |
| material-ui/core | v4.10.2 |
| React | 16.13.1 |
| Browser | Chrome 83.0.4103.61 |
@guimacrf Thanks for taking the time to report the issue What do you think of this patch? Do you want to work on it? :)
diff --git a/packages/material-ui-lab/src/Pagination/usePagination.js b/packages/material-ui-lab/src/Pagination/usePagination.js
index 300ee9574..9464af317 100644
--- a/packages/material-ui-lab/src/Pagination/usePagination.js
+++ b/packages/material-ui-lab/src/Pagination/usePagination.js
@@ -62,7 +62,7 @@ export default function usePagination(props = {}) {
boundaryCount + siblingCount * 2 + 2,
),
// Less than endPages
- endPages[0] - 2,
+ endPages.length > 0 ? endPages[0] - 2 : Infinity,
);
// Basic list of items to render
@oliviertassinari, if @guimacrf doesn't want to take this I'm more than happy to.
@oliviertassinari , I want to work on it. Thanks for the opportunity.
I will reply about your sugestion tonight.
@guimacrf Thanks for taking the time to report the issue What do you think of this patch? Do you want to work on it? :)
diff --git a/packages/material-ui-lab/src/Pagination/usePagination.js b/packages/material-ui-lab/src/Pagination/usePagination.js index 300ee9574..9464af317 100644 --- a/packages/material-ui-lab/src/Pagination/usePagination.js +++ b/packages/material-ui-lab/src/Pagination/usePagination.js @@ -62,7 +62,7 @@ export default function usePagination(props = {}) { boundaryCount + siblingCount * 2 + 2, ), // Less than endPages - endPages[0] - 2, + endPages.length > 0 ? endPages[0] - 2 : Infinity, ); // Basic list of items to render
@oliviertassinari , I made the correction a little differently than you suggested, but following your idea. As you suggested, the last page appeared twice. Take a look:
diff --git a/packages/material-ui-lab/src/Pagination/usePagination.js b/packages/material-ui-lab/src/Pagination/usePagination.js
index 300ee9574..7391b7870 100644
--- a/packages/material-ui-lab/src/Pagination/usePagination.js
+++ b/packages/material-ui-lab/src/Pagination/usePagination.js
@@ -62,7 +62,7 @@ export default function usePagination(props = {}) {
boundaryCount + siblingCount * 2 + 2,
),
// Less than endPages
- endPages[0] - 2,
+ endPages.length > 0 ? endPages[0] - 2 : count - 1,
);
// Basic list of items to render
Sending a pull request in a few minutes.
@guimacrf Thanks for looking into it, Infinity was probably not the best value 馃憤.