Skip to content

Commit 8cec920

Browse files
committed
[pagination] Preserve empty layout when count is zero
Change-Id: I70f691e4bde221894729693c969445e3d9690a9a
1 parent 1ef8311 commit 8cec920

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

packages/mui-material/src/usePagination/usePagination.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default function usePagination(props = {}) {
8383
}
8484

8585
const body =
86-
boundaryCount === 0 && siblingCount === 0
86+
count > 0 && boundaryCount === 0 && siblingCount === 0
8787
? [page]
8888
: [
8989
...startPages,

packages/mui-material/src/usePagination/usePagination.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ describe('usePagination', () => {
161161
});
162162
});
163163

164+
it('does not render a page when count is zero', () => {
165+
const items = renderHook(() => usePagination({ count: 0, boundaryCount: 0, siblingCount: 0 }))
166+
.result.current.items;
167+
168+
expect(serialize(items)).to.deep.equal(['previous', 'next']);
169+
expect(items[0]).to.have.property('disabled', true);
170+
expect(items[1]).to.have.property('disabled', true);
171+
});
172+
164173
it('should support boundaryCount={0}', () => {
165174
const items = renderHook(() =>
166175
usePagination({ count: 11, page: 6, boundaryCount: 0, siblingCount: 1 }),

0 commit comments

Comments
 (0)