[1.0.0-rc3] Pagination removes the bad link from the current page

Created on 29 May 2024, 6 months ago
Updated 23 June 2024, 5 months ago

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".
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇷🇪Réunion Martygraphie Saint-Denis (Réunion)

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024