I ran into this issue will fixing a "bug" on a current project. We have view page, using ajax and a mini-pager. We also have Views Ajax History module turned on. When paging the second time and beyond, you loose the correct url. While investigating this, it seems the mini pager copies a lot from the Full pager, which it should. And the plugin (Drupal\views\Plugin\views\pager\Mini) implements the theme with a variable "#route_name" but never uses it.

So here is a test I did to explain further. There is more to that total issue, but this is the first part for mini-pagers:
Full Pager w/ Views Ajax History:

- Load Page:
- Click Page 2, get
- Click Page 3,[t...

Mini Pager w/ Views Ajax History:

- Load Page,
- Click Next,
- Click Next,[theme]=barti...

Proposed resolution

I believe the views_mini_pager theme needs to add "route_name" as a variable and the preprocess function needs to use the route just like the full pager.

Also, for those that need an immediate fix, this can be accomplished through alters and preprocesses...

function MODULE_theme_registry_alter(&$theme_registry) {
  // Fix core bug with mini pager.
  $theme_registry['views_mini_pager']['variables']['route_name'] = '';

// Overwrite preprocess functions.
function MODULE_preprocess_views_mini_pager(&$variables) {
  global $pager_page_array, $pager_total;

  $tags = &$variables['tags'];
  $element = $variables['element'];
  $parameters = $variables['parameters'];
  $route_name = $variables['route_name'];
  $route_parameters = [];

  // Current is the page we are currently paged to.
  $variables['items']['current'] = $pager_page_array[$element] + 1;

  if ($pager_total[$element] > 1 && $pager_page_array[$element] > 0) {
    $options = [
      'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1),
    $variables['items']['previous']['href'] = \Drupal::url($route_name, $route_parameters, $options);
    if (isset($tags[1])) {
      $variables['items']['previous']['text'] = $tags[1];
    $variables['items']['previous']['attributes'] = new Attribute();

  if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
    $options = [
      'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1),
    $variables['items']['next']['href'] = \Drupal::url($route_name, $route_parameters, $options);
    if (isset($tags[3])) {
      $variables['items']['next']['text'] = $tags[3];
    $variables['items']['next']['attributes'] = new Attribute();

Remaining tasks

I've included a patch

mini-pager-theme.patch2.46 KBpingevt
Members fund testing for the Drupal project. Drupal Association Learn more


pingevt created an issue. See original summary.

Lendude’s picture

Project: Views » Drupal core
Version: 8.x-3.x-dev » 9.x-dev
Component: Code » views.module
Category: Task » Bug report
Issue tags: -ajax pager, -pager, -mini pager
Related issues: +#2866386: 'view_path' is set to /views/ajax after second ajax request

Views is in Drupal core now, moving to the right queue.

Seems related/duplicate of #2866386: 'view_path' is set to /views/ajax after second ajax request, have you tried the patch there?