Problem/Motivation
There is a problem with the Views full pager, the active page number is not showing on the last page when the quantity value is 1.
Steps to reproduce
- Create a view with full pager
- In the pager option the "Number of pager links visible" should be 1
- Go to the view page and go to the last page, the active page is not displaying in the pager
- Change the pager option the "Number of pager links visible" to other values then the active page is displaying in the pager
Proposed resolution
This is because the following code on the template_preprocess_pager is not executing on the last page
if ($i != $pager_max) {
// Add an ellipsis if there are further previous pages.
if ($i > 1) {
$variables['ellipses']['previous'] = TRUE;
}
// Now generate the actual pager piece.
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
$options = [
'query' => $pager_manager->getUpdatedParameters($parameters, $element, $i - 1),
];
$items['pages'][$i]['href'] = Url::fromRoute($route_name, $route_parameters, $options)->toString();
$items['pages'][$i]['attributes'] = new Attribute();
if ($i == $pager_current) {
$variables['current'] = $i;
}
}
// Add an ellipsis if there are further next pages.
if ($i < $pager_max + 1) {
$variables['ellipses']['next'] = TRUE;
}
}
The logic behind the check if ($i != $pager_max) { is not documented.
It does not really add up because in the nested for loop $i is allowed to be equal with $pager_max
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
So remove if ($i != $pager_max) { condition from here.