Fixed a bug where the pager was not constructing elements in the right positions.

This commit is contained in:
2025-06-22 20:09:37 -07:00
parent 80a0e81973
commit 1733df832a

View File

@ -3735,17 +3735,21 @@ class pager extends IgniteTemplate {
//Construct the pages
if (this.pageCount > 0) {
var last = this.element;
//Construct the first page
var firstPage = this.renderCallback(0, this.currentPage == 0, false);
firstPage.construct(parent, this.element);
firstPage.construct(parent, last);
this.pages.push(firstPage);
last = firstPage.element;
//If the number of pages is less than or equal to the page range, just render all the numbers inbetween first/last.
if (this.pageCount <= this.pageRange) {
for (var i = 1; i < this.pageCount - 1; i++) {
var page = this.renderCallback(i, i == this.currentPage, false);
page.construct(parent, this.element);
page.construct(parent, last);
this.pages.push(page);
last = page.element;
}
} else {
var leftSiblingIndex = Math.max(this.currentPage - this.pageRange, 1);
@ -3767,24 +3771,27 @@ class pager extends IgniteTemplate {
if (shouldShowLeftDots) {
var page = this.renderCallback(leftSiblingIndex - 1, false, true);
if (page) {
page.construct(parent, this.element);
page.construct(parent, last);
this.pages.push(page);
last = page.element;
}
}
for (var i = leftSiblingIndex; i <= rightSiblingIndex; i++) {
var page = this.renderCallback(i, i == this.currentPage, false);
if (page) {
page.construct(parent, this.element);
page.construct(parent, last);
this.pages.push(page);
last = page.element;
}
}
if (shouldShowRightDots) {
var page = this.renderCallback(rightSiblingIndex + 1, false, true);
if (page) {
page.construct(parent, this.element);
page.construct(parent, last);
this.pages.push(page);
last = page.element;
}
}
}
@ -3792,8 +3799,9 @@ class pager extends IgniteTemplate {
//Construct the last page if we have more than 1 page.
if (this.pageCount > 1) {
var lastPage = this.renderCallback(this.pageCount - 1, this.currentPage == this.pageCount - 1, false);
lastPage.construct(parent, this.element);
lastPage.construct(parent, last);
this.pages.push(lastPage);
last = lastPage.element;
}
}
}