Skip to content

Commit ae1ce17

Browse files
fix DSpace#5494: enable rotate to show surrounding pages on navigation (DSpace#5505)
1 parent 52cc116 commit ae1ce17

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/app/core/pagination/pagination-component-options.model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export class PaginationComponentOptions extends NgbPaginationConfig {
1919
*/
2020
maxSize = 10;
2121

22+
/**
23+
* Whether to rotate pages towards the current page.
24+
* Ensures the active page is always visible in the pagination control.
25+
*/
26+
rotate = true;
27+
2228
/**
2329
* A number array that represents options for a context pagination limit.
2430
*/

src/app/shared/pagination/pagination.component.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,31 @@ describe('Pagination component', () => {
317317
expect(de.nativeElement.classList.contains('pagination-sm')).toBeTruthy();
318318
});
319319
});
320+
321+
it('should show surrounding pages when navigating to a later page', () => {
322+
testComp.collectionSize = 200;
323+
testComp.paginationOptions.maxSize = 5;
324+
testFixture.detectChanges();
325+
326+
currentPagination.next(Object.assign(new PaginationComponentOptions(), pagination, { currentPage: 10 }));
327+
testFixture.detectChanges();
328+
329+
const paginationDe = testFixture.debugElement.query(By.css('.pagination'));
330+
const activePage = paginationDe.nativeElement.querySelector('li.active');
331+
expect(activePage).toBeTruthy();
332+
expect(activePage.textContent.trim()).toContain('10');
333+
334+
const allPages = paginationDe.nativeElement.querySelectorAll('li');
335+
const pageNumbers = Array.from(allPages).map((li: any) =>
336+
li.textContent.trim().replace(/\s+/g, ''),
337+
).filter(t => /^\d+$/.test(t));
338+
339+
expect(pageNumbers).toContain('8');
340+
expect(pageNumbers).toContain('9');
341+
expect(pageNumbers).toContain('10');
342+
expect(pageNumbers).toContain('11');
343+
expect(pageNumbers).toContain('12');
344+
});
320345
});
321346

322347
describe('when showPaginator is true', () => {

0 commit comments

Comments
 (0)