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.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | Screenshot 2025-01-27 121305.png | 149.98 KB | kushagra.goyal |
Issue fork drupal-3418396
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
Comment #4
goz commentedComment #5
smustgrave commentedThanks for reporting, will need a failing test show the issue.
Comment #7
mbuechner commentedI can confirm this. Here is a (quick) patch for the problem.
Comment #8
mbuechner commentedPlease ignore the previous patch. I have attached the wrong file. :-(
Comment #9
xjmAll 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.
Comment #10
xjmThe 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?
Comment #11
johnvComment #12
kushagra.goyal commentedI 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?
Comment #13
florismoriceauI 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