Hi,

Problem/Motivation

I have encountered a problem with pagination. I am using version RC1 of UI SUITE DSFR and Drupal 10.2. The hook_ui_suite_dsfr_preprocess_pager(array &$variables) function alters page management with the following line:

$variables["items"]["pages"] = LinksSettingType::normalize($variables["items"]["pages"]);

However, before entering the LinksSettingType::normalize function, the $variables["items"]["pages"] array contains the following keys corresponding to the page numbers:

array:6 [▼
  4 => array:2 [▶]
  5 => array:2 [▶]
  6 => array:2 [▶]
  7 => array:2 [▶]
  8 => array:2 [▶]
  9 => array:2 [▶]
]

After passing through the LinksSettingType::normalize function, the array is output with the following keys:

array:6 [▼
  0 => array:3 [▶]
  1 => array:3 [▶]
  2 => array:3 [▶]
  3 => array:3 [▶]
  4 => array:3 [▶]
  5 => array:3 [▶]
]

This results in the loss of the page index, and as a result, the following code:

$current = $variables["current"] - 1;
unset($variables["items"]["pages"][$current]["url"]);

cannot function correctly and leads to inconsistent pagination

Suggested Solution

  • Either find an alternative to LinksSettingType::normalize.
  • Remove the two lines causing the malfunction and manage the deletion of the URL by searching for the page with the attribute aria-current="page".
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Martygraphie created an issue. See original summary.

martygraphie’s picture

Status: Active » Needs review
martygraphie’s picture

Title: Pagination removes links from the wrong page » Pagination removes the bad link from the current page
pdureau’s picture

Assigned: Unassigned » pdureau

  • pdureau committed dfab9e9e on 1.0.x authored by Martygraphie
    Issue #3450577 by Martygraphie: Pagination removes links from the wrong...
pdureau’s picture

Title: Pagination removes the bad link from the current page » [1.0.0-rc3] Pagination removes the bad link from the current page
Assigned: pdureau » Unassigned
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.