Exposed Filter in Views Redirects to Page Display Path Instead of Block Path

Created on 19 July 2024, 5 months ago

Problem/Motivation

When creating a view in Drupal with an exposed filter, and then embedding this view as a block on a specific page, the user is redirected to the page display path of the view when applying the filter, instead of staying on the same page where the block is embedded.

Steps to reproduce

Install Drupal 10.3.1 with the standard profile.
Add a new "Test view" view with default settings (Show: Content of type: All, etc.).
Click "Save and edit".
Add a new filter for Content type and enable the "Expose this filter to visitors, to allow them to change it" option. Save the settings.
Add a new Block display to the view.
Add a new Page display to the view.
Set the path for the Page display to "test-view".
Save the view.
Create a new "Basic page" node with the title "Test page" and the URL alias "Test". Save the node.
Navigate to Structure > Block layout and click "Place block" in the Content region.
Find the "Test view" block and click "Place block".
In the Visibility section, go to the Pages tab and enter "/test". Save the block.
Open the "/test" URL and observe the page with the injected view block containing the exposed Content type filter.
Select any value from the Content type dropdown and press Apply.

Expected Behavior:
The user remains on the same page, and the view block updates to show the filtered results.

Actual Behavior:
The user is redirected to the "/test-view" URL, the path set for the view page display, causing confusion and navigation issues.

🐛 Bug report
Status

Active

Version

10.3

Component
Views 

Last updated 2 days ago

Created by

🇺🇸United States xopoc

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @xopoc
  • 🇮🇳India DimpleL

    Hi, As a workaround, you can use the setting available under Advanced called "Use AJAX." Setting "Use AJAX" to "yes" will resolve the issue for now.

  • Status changed to Closed: works as designed 5 months ago
  • 🇳🇱Netherlands Lendude Amsterdam

    This is by design, Views will look for the first display with a path and use that. You can try #2 or make the block and page be separate Views and not 2 displays on the same View.

  • 🇺🇸United States RichardDavies Portland, Oregon

    I'm sorry, but if this is "works as designed" then I think this is poorly designed. Please explain to me why I'd want the exposed filters in my view block to target another random display in that view. You said it uses the "first" display with a path, but it doesn't use the first display according to the configured display order within the view, it uses the first display defined in the view's YAML config file.

    If this works as expected with a view containing only a single block, then it should work the same with a block in a view that also contains other displays.

  • 🇺🇸United States RichardDavies Portland, Oregon

    There's a similar problem if you enable Views Bulk Operations on a view embedded as a block. The bulk operations also incorrectly target the wrong page path. However, in this case, enabling AJAX doesn't work as a workaround. So you're telling me that now I need to recreate this block in a completely new separate view and reconfigure my pages/blocks just because I've added bulk operations and this is by design?

Production build 0.71.5 2024