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_id
s.
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
- Enable the Layout Builder module
- Add multiple Articles nodes to test the pager with
- 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
- Create a new vocabulary that uses Layout Builder for the default display mode
- Manage the layout for the new vocabulary and add a new section with the AJAX view inside
- Add a term to the new vocabulary and view it on the front end
- 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