File tree Expand file tree Collapse file tree 3 files changed +3
-3
lines changed
Expand file tree Collapse file tree 3 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ test('displays an out of range page', () => {
9393 items : processed ,
9494 pagesCount,
9595 actualPageIndex,
96- } = processItems ( items , { currentPageIndex : 3 } , { pagination : { } } ) ;
96+ } = processItems ( items , { currentPageIndex : 3 } , { pagination : { allowPageOutOfRange : true } } ) ;
9797 expect ( actualPageIndex ) . toEqual ( 3 ) ;
9898 expect ( pagesCount ) . toEqual ( 2 ) ;
9999 expect ( processed ) . toHaveLength ( 0 ) ;
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export interface UseCollectionOptions<T> {
4444 freeTextFiltering ?: PropertyFilterFreeTextFiltering ;
4545 } ;
4646 sorting ?: { defaultState ?: SortingState < T > } ;
47- pagination ?: { defaultPage ?: number ; pageSize ?: number } ;
47+ pagination ?: { defaultPage ?: number ; pageSize ?: number ; allowPageOutOfRange ?: boolean } ;
4848 selection ?: {
4949 defaultSelectedItems ?: ReadonlyArray < T > ;
5050 keepSelection ?: boolean ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export function createPageProps<T>(
1616 const pageSize = pagination . pageSize ?? DEFAULT_PAGE_SIZE ;
1717 const pagesCount = Math . ceil ( items . length / pageSize ) ;
1818 let pageIndex = currentPageIndex ?? 1 ;
19- if ( pageIndex < 1 || Number . isNaN ( pageIndex ) ) {
19+ if ( pageIndex < 1 || ( pageIndex > pagesCount && ! pagination . allowPageOutOfRange ) || Number . isNaN ( pageIndex ) ) {
2020 pageIndex = 1 ;
2121 }
2222 return { pageSize, pagesCount, pageIndex } ;
You can’t perform that action at this time.
0 commit comments