Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 303429

Pager pagination with AJAX incorrect when rendered through layout builder

$
0
0

Problem/Motivation

When rendering a view with an AJAX pager through layout builder, either directly or through other means (e.g. Views Reference Field on a content block), the pager does not receive the AJAX behavior, and instead reloads the page with the non-AJAX page query parameter appended.

At first glance it doesn't appear to be an issue with what's being #attached to the view. I've inspected both renderings through a post-render hook in a custom module, see below, and the only differences are the ones you'd expect such as their respective view_dom_ids.

function hook_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {
  dpm($view->element['#attached'], $view->id());
}

The rendering within Layout Builder has no trace of data-once="ajax-pager". Inspecting drupalSettings.views shows the view is found, though it doesn't receive the behavior.

If I render the view on the same page through a region, it receives the intended ajax-pager behavior.

At this point I have exhausted my knowledge on both the Layout Builder and Views APIs. Further debugging from those with more intimate knowledge of the aforementioned APIs would be much appreciated.

I have been able to reliably reproduce this issue using a standard DDEV install on Drupal 10.3.1 and PHP 8.3.

Steps to reproduce

  1. Enable the Layout Builder module
  2. Add multiple Articles nodes to test the pager with
  3. Create a content view with an AJAX pager, either full or mini, and set a per-page count smaller than the amount of nodes you created so paging can be tested
  4. Create a new vocabulary that uses Layout Builder for the default display mode
  5. Manage the layout for the new vocabulary and add a new section with the AJAX view inside
  6. Add a term to the new vocabulary and view it on the front end
  7. Interact with the AJAX view's pager and observe a page reload with the non-AJAX page query parameter appended

Proposed resolution

TBD

Remaining tasks

  • Find the cause of the issue
  • Implement a fix

Viewing all articles
Browse latest Browse all 303429

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>