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.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comments
Comment #2
cilefen commentedComment #3
ranjith_kumar_k_u commentedA quick fix
Comment #4
ranjith_kumar_k_u commentedComment #5
Manibharathi E R commentedPatch #3 Applied and Tested successfully on Drupal 9.5.x.
Before Patch:

After Patch:

Comment #6
gaurav-mathur commentedPatch #3 do great work and Tested successfully on Drupal 9.5.x.
Thanks and Regards .
Comment #7
prasanth_kp commented#3 Patch Applied on 9.5.x-dev and it fixes the issue.
Comment #8
heni_deepak commentedComment #9
lendudeThis is not a proper English sentence. Maybe:
"Make sure the current page is shown if only one page number is shown."
or something?
can we use '===' ?
Is all this really needed? Why is the link removed in the first place? Seems like we should do some more digging into why this breaks at all.
Also, this needs a test. And since the current fix has nothing to do with Views, this seems like a more general problem? But no idea which component this should go into, 'base system' sounds a bit weak too....
Comment #10
martins.bertins commentedhttps://git.drupalcode.org/project/drupal/-/blob/9.5.x/core/includes/the...
This part is never executed for last page if pager quantity is set to 1. Unfortunately the logic behind the check
if ($i != $pager_max) {is not documented.It does not really add up because in the nested for loop
$iis allowed to be equal with$pager_maxfor (; $i <= $pager_last && $i <= $pager_max; $i++) {Created a new patch that disables the check in question. Needs tests though.
Comment #11
martins.bertins commentedChanging component
Comment #12
ranjith_kumar_k_u commentedAdded tests, please review
Comment #14
smustgrave commentedIssue summary needs to be updated for missing parts.
Comment #15
ranjith_kumar_k_u commentedComment #16
smustgrave commentedConfirmed on 11.x that the last page of a view has the active page link.
Comment #19
lauriiiMade minor adjustments to the test on commit; adjusted the wrapping of the comment and simplified the selector a bit.
Committed 3da8c30 and pushed to 11.x. Also cherry-picked to 10.1.x. Thanks!
Not going to backport to 10.0.x or 9.5.x because there's a small behavior change.