Problem/Motivation
In Drupal 11.3.x, Views AJAX automatically triggers two behaviors:
- Updates the browser URL using
SetBrowserUrl - Scrolls to the top of the view using
ScrollTopCommandwhen a pager is present
These behaviors are always enabled and cannot be controlled via the UI.
This creates several issues:
- Breaks custom frontend logic (SPA-like behavior, manual history handling)
- Interferes with analytics tracking (e.g., gtag-based navigation tracking)
- Causes poor UX due to unexpected scroll-to-top behavior, especially on initial load
- Forces developers to patch core to disable these features
Steps to reproduce
- Create a View with:
- AJAX enabled
- Pager enabled
- Place the View on a page
- Load the page and interact with pagination
Observed:
- URL is automatically updated with query parameters (e.g.,
?page=1) - View scrolls to top when pager is triggered (and sometimes on initial load depending on implementation)
Proposed resolution
Introduce configurable options in Views UI to control AJAX behavior.
Add new settings under AJAX configuration:
update_browser_url(boolean, default: TRUE)scroll_to_top(boolean, default: TRUE)
Update ViewAjaxController to conditionally execute commands:
-
Only trigger
ScrollTopCommandwhen:- Pager interaction occurs (
pagequery param exists) - AND
scroll_to_topis enabled
- Pager interaction occurs (
-
Only trigger
SetBrowserUrlwhen:update_browser_urlis enabled
This preserves backward compatibility while allowing flexibility.
Remaining tasks
- [ ] Add new display options to Views UI (AJAX settings section)
- [ ] Define schema for new configuration options
- [ ] Update
ViewAjaxControllerlogic to respect settings - [ ] Add functional/kernel tests for:
- URL update toggle
- Scroll behavior toggle
- [ ] Update documentation
- [ ] Provide backward compatibility coverage
User interface changes
Add two checkboxes under Views → Advanced → AJAX settings:
- [ ] Update browser URL on AJAX requests (default: checked)
- [ ] Scroll to top on pager interaction (default: checked)
No changes to existing UI behavior unless user modifies settings.
Introduced terminology
None.
API changes
- New optional display configuration:
ajax_settings.update_browser_urlajax_settings.scroll_to_top
- No breaking API changes
- Existing behavior remains default
Data model changes
- Add new configuration keys to Views display configuration
- Requires updates to Views schema definition
Release notes snippet
Views AJAX behavior is now configurable. Site builders can disable automatic browser URL updates and scroll-to-top behavior via new options in the Views UI. This improves flexibility for custom frontend integrations and user experience control.
Comments
Comment #2
yusuf_khan commentedComment #3
quietone commentedFor Drupal core, it is preferred that contributors add a comment that they are working on an issue instead of assigning it to themselves. See Assigning ownership of a Drupal core issue.
Comment #4
yusuf_khan commentedThanks for the clarification.Unassigned