Pagination Issues: first/last links missing and next/prev links show as numbers
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3561118. --> Reported by: [circuitcipher](https://www.drupal.org/user/3849396) Related to !110 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The pager provided by the UI Suite USWDS theme has two significant bugs that result in a poor user experience:</p> <ol> <li>The "first" and "last" pagination links are never rendered, even on pages where they would be appropriate (i.e., any page except the very first or very last).</li> <li>The "previous" and "next" links are displayed with page numbers as their text instead of the human-readable labels "Previous" and "Next".</li> </ol> <p>This behavior deviates from the USWDS design standards and standard pagination usability patterns, making navigation more difficult for users.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <ol> <li>Install and enable the <code>ui_suite_uswds</code> theme.</li> <li>Create a view or any content list with a pager that has more than 5 pages of results.</li> <li>Navigate to any page other than the first page.</li> <li><strong>Expected behavior:</strong> You should see "First", "Previous", "Next", and "Last" links, clearly labeled.</li> <li><strong>Actual behavior:</strong> The "First" and "Last" links are missing entirely. The "Previous" and "Next" links appear, but their link text is a number (e.g., "2") instead of the word "Previous" or "Next".</li> </ol> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>The issue stems from two places: the preprocess function that prepares the pager variables and the Twig template that renders them.</p> <p>The fix involves two main changes:</p> <ol> <li> <strong>Update the Preprocess Logic:</strong> In <code>PreprocessPager.php</code>, the code that explicitly unsets the 'first' and 'last' links from the items array has been removed. The original implementation filtered them out, which was the direct cause of them not appearing. The updated logic now correctly includes them in the array passed to the template. </li> <li> <strong>Update the Twig Template:</strong> In <code>pagination.twig</code>, the rendering logic for the navigation links has been corrected. <ul> <li>The template now uses the <code>aria-label</code> attribute (e.g., "Previous", "Next", "First", "Last") to display the link text for the directional and boundary links, rather than using <code>item.title</code>, which incorrectly contains a page number for these elements.</li> <li>The "First" and "Last" links are now rendered with their text labels and icons, consistent with the "Previous" and "Next" links, instead of attempting to render page numbers.</li> </ul> </li> </ol> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>None. The proposed resolution fully addresses the issue.</p> <h3 id="summary-ui-changes">User interface changes</h3> <p>The pager component will be rendered correctly according to USWDS standards. "First" and "Last" links will now be visible when appropriate, and the "Previous" and "Next" links will be labeled with text instead of page numbers, providing a more intuitive navigation experience.</p> <h3 id="summary-api-changes">API changes</h3> <p>None.</p> <h3 id="summary-data-model-changes">Data model changes</h3> <p>None.</p>
issue