Problem/Motivation

When a view loaded via lazy_views has use_ajax: TRUE on its display, the browser's URL bar is silently rewritten to the site's front page as soon as the view finishes loading.

This was harmless prior to Drupal 11.3 because the views AJAX controller didn't update the browser URL. Drupal 11.3's new SetBrowserUrl command exposed the missing view_path in lazy_views' payload.

Proposed resolution

Pass the current page path so the controller either resolves to the correct origin URL or skips SetBrowserUrl when the path isn't a valid route.

Issue fork lazy_views-3590330

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

cindytwilliams created an issue. See original summary.

cindytwilliams’s picture

Status: Active » Needs review
b_sharpe’s picture

I haven't had a chance to look/test yet, but immediately I wonder if query string or hash matters here? I imagine you want to retain these as well.

Either like:

view_path: window.location.pathname + window.location.search + window.location.hash,

or maybe:

view_path: window.location.href.replace(window.location.origin, ''),
cindytwilliams’s picture

Issue summary: View changes
cindytwilliams’s picture

Having just window.location.pathname matches what core's Drupal.Views.ajaxView (in core/modules/views/js/ajax_view.js) sends as view_path, which is the route path only.

Core handles the query string separately. ViewAjaxController reads the AJAX request's query params and reattaches them to $target_url.

cindytwilliams’s picture

  • 36965013 committed on 1.0.x
    Issue #3590330: Pass view_path so AJAX-loaded views don't rewrite URL to...
b_sharpe’s picture

Status: Needs review » Fixed

Good enough for me, tested and working. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.