Problem/Motivation

If you have a pagination with links without href in a views with ajax, javascript will break with error :


Uncaught TypeError: query is undefined
parseQueryString /core/modules/views/js/base.js
attachPagerLinkAjax /core/modules/views/js/ajax_view.js

Steps to reproduce

  • Use a template of pagination which display a link without href attribute. Exampe in https://www.drupal.org/project/ui_suite_dsfr/releases/1.0.0-beta5
  • Create a views with full pagination and enable ajax.
  • Be sure to have a lot of content, enough to have more pages than the limit that is displayed, so ellipses are displayed.
  • Go to the view
  • Error is displayed in console.
  • Click to a link of the pagination, page will be reloaded, no ajax.

Proposed resolution

"href" attribute is not required in "a" tag, so code should not assume "a" tag has this attribute.

Issue fork drupal-3418396

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

GoZ created an issue. See original summary.

GoZ changed the visibility of the branch 11.x to hidden.

goz’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Thanks for reporting, will need a failing test show the issue.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mbuechner’s picture

Version: 11.x-dev » 10.2.x-dev
StatusFileSize
new540 bytes

I can confirm this. Here is a (quick) patch for the problem.

mbuechner’s picture

StatusFileSize
new464 bytes

Please ignore the previous patch. I have attached the wrong file. :-(

xjm’s picture

Version: 10.2.x-dev » 11.x-dev

All changes go into 11.x first. Also, we should not create patch files when there is already a merge request, so @mbuechner please work on the MR instead to receive credit for contributing to the issue. :)

Hiding the patch files.

xjm’s picture

The eslint job is failing, but I wasn't able to understand why from the logs. I reran it to confirm. Maybe someone could run the esllint job locally and see what coding standards issues there might be?

johnv’s picture

Title: Ajax pagination is broken when some links has no href » Pager pagination with ajax is broken when some links has no href
kushagra.goyal’s picture

StatusFileSize
new149.98 KB

I recently performed a fresh Drupal installation and used the Devel module's content generator to create multiple article nodes. After creating a View with a full pager to display the articles, I encountered an Html::escape() error when previewing the View. Has anyone faced a similar issue or knows how to resolve this?

florismoriceau’s picture

I encountered the same issue on a Drupal 10.3 website, with a themed pager base on ui_suite_dsfr.
The patch works fine.

Thank you @goz

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.