Problem/Motivation

If there is a View that has exposed filters and then you place multiple of those views on a page, the filters do not work correctly.

What should happen is that each instance of the block can have a different filter setting and display different content.

What happens is that changes made to either filter effect only the content displayed by the second Views block. The Ajax spinner stays on the page. Both filter forms have the same id attribute which is invalid HTML.

Steps to reproduce

Scenario #1
Create a Views block with exposed filters set to use Ajax.
Place this block more than once on the same page using Layout Builder.
Change the filter.

Scenario #2
Create a view with 2 blocks
Make the second one use ajax and have exposed filters
Place on a page
Notice that the ajax on the second page first once and then throws errors about offset.top() being null
Moving second block to above the first fixed it but that shouldn't be the fix

Proposed resolution

Set a new attribute on the view block 'data-drupal-target-view' and use that to determine relationship between view and exposed form block

Remaining tasks

Review

User interface changes

NA

Introduced terminology

NA

API changes

New attribute being added to the view block 'data-drupal-target-view'

Data model changes

NA

Release notes snippet

NA

CommentFileSizeAuthor
#141 interdiff_3163299_110_140.txt720 bytes_pratik_
#140 3163299_140_d10.2.patch23.02 KB_pratik_
#139 core_ajax-exposed-filters-not-working-for-multiple-instances-3163299-139.patch31.96 KBsanderjp
#128 3163299-126-ajax-exposed-filters-not-media-library.patch30.2 KBltrain
#120 3163299_120_d10.3.5.patch23.04 KBericdsd
#110 3163299-110-D10.2.patch22.28 KBpeachez
#104 3163299-104-D9.patch24.6 KBtaran2l
#104 3163299-104-D10.patch22.88 KBtaran2l
#103 interdiff-93-103.txt12.83 KBtaran2l
#103 3163299-103-D9.patch24.66 KBtaran2l
#103 3163299-103-D10.patch23.03 KBtaran2l
#101 3163299-101-D10.patch22.93 KBtaran2l
#100 interdiff-93-99.txt5.42 KBtaran2l
#100 3163299-100-D10.patch22.96 KBtaran2l
#99 3163299-99.patch24.67 KBtaran2l
#98 3163299-98.patch24.69 KBtaran2l
#96 3163299-96.patch23.8 KBtaran2l
#95 3163299-95.patch23.82 KBtaran2l
#94 3163299-94.patch23.82 KBtaran2l
#93 3163299-93.patch24.09 KBrodrigoaguilera
#92 interdiff.txt1.72 KBrodrigoaguilera
#92 3163299-92.patch0 bytesrodrigoaguilera
#82 3163299-82-9.5.x.patch21.26 KBlarowlan
#80 3163299-80.patch23.58 KBgauravvvv
#80 interdiff-77_80.txt1.64 KBgauravvvv
#79 3163299-79.patch21.93 KBgauravvvv
#77 3163299-77.patch21.9 KBcpierce42
#75 3163299-75.patch21.74 KBcpierce42
#72 interdiff-3163299-68-72.txt4.93 KBmohit_aghera
#72 3163299-72.patch22.91 KBmohit_aghera
#68 3163299-68.patch19.77 KBameymudras
#66 3163299-66.patch24.52 KBstefank
#64 3163299-64.patch23.72 KBtim@lammar.be
#59 interdiff_57-59.txt554 bytesranjith_kumar_k_u
#59 3163299-59.patch24.54 KBranjith_kumar_k_u
#54 3163299-54.patch24.58 KBseanb
#54 interdiff-49-54.txt2.14 KBseanb
#51 3163299-51.patch24.25 KBseanb
#51 interdiff-49-51.txt1.82 KBseanb
#49 interdiff_48-49.txt282 bytesranjith_kumar_k_u
#49 3163299-49.patch22.81 KBranjith_kumar_k_u
#48 3163299-48-9.3.x.patch22.99 KBseanb
#33 interdiff-18-31.txt8.69 KBliam morland
#31 interdiff_30-31.txt6.59 KBraman.b
#31 3163299-31.patch21.27 KBraman.b
#31 3163299-31-test-only.patch14.89 KBraman.b
#30 interdiff_29-30.txt6.12 KBraman.b
#30 3163299-30.patch20.71 KBraman.b
#29 interdiff_18-29.txt7.61 KBraman.b
#29 3163299-29.patch20.79 KBraman.b
#29 3163299-29-test-only.patch14.42 KBraman.b
#20 3163299-18-test-only.patch14.24 KBtaran2l
#18 3163299-18.patch21.16 KBtaran2l
#15 3163299-15-test-only.patch14.26 KBtaran2l
#15 3163299-15.patch23.11 KBtaran2l
#14 3163299-14.patch9.05 KBtaran2l
#12 3163299-12.patch8.11 KBtaran2l
#10 3163299-10.patch4.63 KBtaran2l
#9 3163299-9.patch4.56 KBtaran2l
#5 drupal-views_form_getUniqueId-3163299-5-D8.patch942 bytesliam morland

Issue fork drupal-3163299

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

ebremner created an issue. See original summary.

larowlan’s picture

Status: Active » Closed (works as designed)

To instances of the same form id will always work this way

larowlan’s picture

Issue tags: +Bug Smash Initiative
liam morland’s picture

Status: Closed (works as designed) » Active
Related issues: +#3163287: Multiple views on same page, filters apply to all, instead of one instance

This is the use case: In Layout Builder, we want to add the same block to the page more than once, but configured differently each time. If we can't do this, we would have to make more than one identical block type with just a different name and be careful to only add each one once.

As it is, when I add more than one instance of a block containing a View with an exposed filter, the filter forms have the same id attribute. This creates invalid HTML, which Drupal ought to prevent. The forms also don't work as expected.

liam morland’s picture

Status: Active » Needs review
StatusFileSize
new942 bytes

This patch fixes the problem of multiple forms having the same id attribute.

The Views exposed filters still do not work. They are configured to use Ajax, but they still do a page refresh and use the filtering information from the query string in the URL. This is why multiple View blocks use the same filter settings. Ajax filtering needs to work properly for multiple blocks to work.

Status: Needs review » Needs work

The last submitted patch, 5: drupal-views_form_getUniqueId-3163299-5-D8.patch, failed testing. View results

liam morland’s picture

Title: Multiple views on same page, filters apply to all, instead of one instance » Ajax exposed filters not working for multiple Views blocks embedded in Layout Builder
Issue summary: View changes
Status: Needs work » Active

Updated steps to reproduce.

liam morland’s picture

I have discovered that having two different Views blocks with exposed filters will not work correctly. It looks like it only works to have one set of exposed filters per page.

taran2l’s picture

Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new4.56 KB

Here's the patch for the issue. It's not ideal, but afaik there is no way to determine the relation between a view and a exposed form, especially in a complex cases.

taran2l’s picture

StatusFileSize
new4.63 KB

OK, let's try another one

Status: Needs review » Needs work

The last submitted patch, 10: 3163299-10.patch, failed testing. View results

taran2l’s picture

Status: Needs work » Needs review
StatusFileSize
new8.11 KB

Well, removing form ID altogether was too radical :)

Status: Needs review » Needs work

The last submitted patch, 12: 3163299-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

taran2l’s picture

Status: Needs work » Needs review
StatusFileSize
new9.05 KB

As views exposed form IDs are unique now, loading a form with AJAX adds a random string to the ID. Patch updated

taran2l’s picture

StatusFileSize
new23.11 KB
new14.26 KB

Adding a test showing the issue

Status: Needs review » Needs work

The last submitted patch, 15: 3163299-15-test-only.patch, failed testing. View results

taran2l’s picture

Hm, #15 looks like a random failure, and the test only patch does not work as expected, but for the sake of purity it should be changed to rely on the old markup

taran2l’s picture

Version: 8.9.x-dev » 9.2.x-dev
StatusFileSize
new21.16 KB

Let's try D9.2 version, as this won't be committed to D8.9.x (I guess)

taran2l’s picture

Status: Needs work » Needs review
taran2l’s picture

Title: Ajax exposed filters not working for multiple Views blocks embedded in Layout Builder » Ajax exposed filters not working for multiple instances of the same Views block placed on one page
Issue tags: -Needs tests
StatusFileSize
new14.24 KB

Alright, and here is a test-only-patch that does fail "correctly"

taran2l’s picture

There is a very similar issue with D7 #1735096: Allow multiple instances of the same exposed filter form on a single page. The proposed patch is almost the same, however, there are updates to the form caching.

Status: Needs review » Needs work

The last submitted patch, 20: 3163299-18-test-only.patch, failed testing. View results

taran2l’s picture

Status: Needs work » Needs review

OK, the test-only patch fails as expected

lendude’s picture

Nice coverage. What we do need to check in the test though that the reload is actually done with AJAX. Calling $assert_session->assertWaitOnAjaxRequest(); doesn't assure that AJAX was used, it could just be that the page reloaded. I'm saying this because some JS changes lead to AJAX stopping to work at all and the exposed form reverting back to just triggering page reloads.

And if at all possible we should get rid of $assert_session->assertWaitOnAjaxRequest(); and replace this with a waitForXYZ method to be more specific in the waits. $assert_session->assertWaitOnAjaxRequest(); leads to random fails unfortunately :(

taran2l’s picture

@Lendude actually it uses AJAX, and without AJAX it will fail because all forms will have the same value (because there are 3 instances of the same form with the same form elements with the same name) -> all views will have the same filter applied and the test will fail. Works by side effect :)

Anyway, I was not aware of the potential issues caused by using $assert_session->assertWaitOnAjaxRequest(). Will try to update the test whenever I have spare time.

liam morland’s picture

@Taran2L, is the patch in #18 the same as #15 except ported to 9.2.x? We need to use this on 8.9.x. Thanks

liam morland’s picture

I'm trying patch #15 on 8.9. It's working except that the reset buttons redirect me to <view-matchine-name>/all/all/all instead of resetting by ajax.

Update: I re-installed my site and I am no longer seeing the above problem.

raman.b’s picture

StatusFileSize
new14.42 KB
new20.79 KB
new7.61 KB

Replacing usages of $assert_session->assertWaitOnAjaxRequest(); and fixing some minor nits.

raman.b’s picture

StatusFileSize
new20.71 KB
new6.12 KB

Should probably get $assert_session back since it was already there

raman.b’s picture

StatusFileSize
new14.89 KB
new21.27 KB
new6.59 KB

Also, just realized that we should have more specific selectors

The last submitted patch, 31: 3163299-31-test-only.patch, failed testing. View results

liam morland’s picture

StatusFileSize
new8.69 KB

The patch in #31 is the same as the patch in #18 except for assertWaitOnAjaxRequest() being replaced with waitForElement() and waitForElementRemoved() in tests, and some coding standards fixes. An interdiff is attached.

taran2l’s picture

Looks good to me, I was deliberately avoiding such precise selectors (so less dependency on the markup), but seems like this is the preferred way

liam morland’s picture

I have created an issue branch with the patches from #18 and #31, and made a merge request.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

Great work here. I just ran into the other case - I have a view consisting of two (or more) blocks (or other view displays), in my example a Map and a results list.

When a user filters the results, all displays of the view should show the same results. On the map and in the result list. I'm not sure if this is or should be in the focus of this issue, but perhaps someone might use this "bug" as expected behavior. Furthermore, it could be helpful to introduce an option to configure that behavior?

marcvangend made their first commit to this issue’s fork.

marcvangend’s picture

I fixed core/modules/views/js/ajax_view.es6.js in the issue fork to comply with prettier formatting. That solves the "Custom Commands Failed" test failure.

That said, to move this forward I assume the issue branch should be rebased on upstream 9.4.x, and the MR updated accordingly, but I'm not sure how to do that.

liam morland’s picture

It needs to be manually rebased in a local repository.

marcvangend’s picture

Version: 9.3.x-dev » 9.4.x-dev

OK, I rebased against 9.4.x. There was a little bit of conflict resolving involved, but I think I got it all sorted out.

Since the rebase required me to do git push --force, anyone who has already checked out the issue fork will probably need to do a hard git reset before continuing to work on it.

marcvangend’s picture

Status: Needs review » Needs work

I couldn't yet figure out why the test is failing.

It fails in \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testExposedBlock where it loops over the select options and clicks the apply button for each option. The second iteration of the foreach, $elements[0]->find('css', 'select') returns NULL instead of the expected NodeElement object.

[update]
The part of testExposedBlock mentioned above was added in issue #2681947: Allow 'Put the exposed form in a block' setting to be used with views block displays and committed on the 9.3.x branch in June. So at least that explains why this did not fail before, but only now after rebasing from 9.2.x onto 9.4.x.

marcvangend’s picture

All right, I think I found the problem. As said, inside the foreach loop in testExposedBlock, the apply button of the exposed form is clicked. Obviously this triggers a page reload. Before the changes in this issue, the form's id attribute remained the same, so the next iteration could reuse the xpath reference to the form element. This magically worked, even across page loads, but IMHO this was lazy test design waiting to break. I will push a new commit which finds the current form element inside the foreach.

marcvangend’s picture

Status: Needs work » Needs review
Belialius’s picture

3163299-31.patch cannot be applied after drupal core update to version 9.3.0

akhildev.cs’s picture

hi,
check the merge request.(req 88)
patch apply form #45 is working fine for me. (patch applied successfully, view block results are the same on the page. )
patch applied on Drupal 9.4.x-dev.
thankyou.

seanb’s picture

StatusFileSize
new22.99 KB

Here is a patch of the latest MR for 9.3.x.

ranjith_kumar_k_u’s picture

StatusFileSize
new22.81 KB
new282 bytes
pyrello’s picture

As far as I can tell, no one ever addressed the question in #38 by @Anybody. It seems like a potentially valid use case where you want to have one exposed filter block and multiple view block instances that update based on which exposed filters are selected. It seems like the code changes here would disrupt that possibility.

Wondering what this would look like in terms of settings that allow for controlling the behavior. Possibly a view block allow setting to "Choose whether block is unique or connected to other instances." Then a corresponding checkbox in the block form to make the block "Unique" in that it has its own HTML identifier. If it was not unique, then it would fall back to a shared HTML identifier.

seanb’s picture

StatusFileSize
new1.82 KB
new24.25 KB
+++ b/core/modules/views/js/ajax_view.js
@@ -66,7 +66,7 @@
+    this.$exposed_form = $("form.views-exposed-form[data-drupal-target-view=\"".concat(settings.view_dom_id, "\"], form.views-exposed-form[data-drupal-target-view=\"").concat(settings.view_name, "-").concat(settings.view_display_id, "\"]"));
     once('exposed-form', this.$exposed_form).forEach($.proxy(this.attachExposedFormAjax, this));

Just noticed something interesting going on here. The code originally selects a single form, and then calls attachExposedFormAjax. With the patch applied, this.$exposed_form contains multiple forms, and attachExposedFormAjax is called for each form with the same context. attachExposedFormAjax uses this.$exposed_form as a context to find submit buttons, which will cause each form to attach the same AJAX request to all forms (so 3 forms will cause all 3 forms to perform 3 AJAX requests on submit).

We should probably use the passed element to find submit buttons in attachExposedFormAjax. Attached patch seems to fix the issue.

Status: Needs review » Needs work

The last submitted patch, 51: 3163299-51.patch, failed testing. View results

seanb’s picture

Not sure why this fails the new test. Might be an issue with the test somehow relying on Drupal.ajax being attached multiple times to each button?

seanb’s picture

StatusFileSize
new2.14 KB
new24.58 KB

Found there was a problem using entity browser with the patch #51. Changed the approach a bit and use once() to make sure the AJAX calls are only attached once to each button.

dravenk’s picture

Issue tags: +Needs re-roll

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

eric_a’s picture

Issue tags: -Needs re-roll +Needs reroll
liam morland’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

Rerolled with the "Rebase" button in GitLab. I think anyone can do this if they click on "Get push access" in the ticket first.

ranjith_kumar_k_u’s picture

StatusFileSize
new24.54 KB
new554 bytes

Status: Needs review » Needs work

The last submitted patch, 59: 3163299-59.patch, failed testing. View results

stefuuuuu made their first commit to this issue’s fork.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dpfitzsi’s picture

It looks like the patch no longer applies in 9.4.8 (#54 works on 9.4.7).

tim@lammar.be’s picture

StatusFileSize
new23.72 KB

Made a quick change so the patch applies again.

bbu23’s picture

While the patch in #64 is applying successfully, it doesn't really work as expected. Views with ajax enabled + 2 instances of the exposed form block (Basic style or BEF, tried both) do not do an ajax submit, but it rather refreshes the page which is not the intended behavior.

stefank’s picture

StatusFileSize
new24.52 KB

Hi all,

I can confirm #54 works on 9.4.x
Also, tried patches from https://www.drupal.org/project/drupal/issues/2968207, but none of the patches worked, meaning, views with exposed filters using Ajax just refreshed the page rather then submits using Ajax.
Attaching a reroll, as the patch doesnt apply cleanly on 9.4.x

dpfitzsi’s picture

The patch in #66 does not apply against 9.4.8.

ameymudras’s picture

Status: Needs work » Needs review
StatusFileSize
new19.77 KB

Re-rolling the above patch for Drupal 10x, couldn't generate a interdiff

Status: Needs review » Needs work

The last submitted patch, 68: 3163299-68.patch, failed testing. View results

charly71’s picture

#54 and #66 do not apply against 9.4.8

PS: #66 has wrong paths with "web" folder..

liam morland’s picture

Instead of posting a new patch, it would be better to update the merge request.

mohit_aghera’s picture

Status: Needs work » Needs review
StatusFileSize
new22.91 KB
new4.93 KB

Hi @Liam Morland
That makes sense.
I think you are the owner of PR https://git.drupalcode.org/project/drupal/-/merge_requests/88#note_110635
So may be, you'll have to rebase the PR and change the destination branch to 9.5.x, since it will be the active branch.
After doing that, we will have the working PR/patch for the 9.5.x branch as well.

Meanwhile, I have ported the patch for 10.1.x and fixed test case failures.
All 3 failing tests in #68 are passing on local now.

liam morland’s picture

I changed the branch to 10.1.x. You should be able to get push access to update it.

cpierce42’s picture

I was using patch 59, which has stopped working for me in Core 9.4.8. Patch 72 does not apply to Core 9.4.8. I have a use case in 9.4.8 where this applies.

cpierce42’s picture

StatusFileSize
new21.74 KB

Uploading patch that works with Drupal 9.4.8 as I have critical need of it. Someone else might too.

dpfitzsi’s picture

Thank you @cpierce42. I have confirmed that the patch applies on 9.4.8.

cpierce42’s picture

Version: 10.1.x-dev » 9.4.x-dev
StatusFileSize
new21.9 KB

Re-rolled the patch for 9.4.8 with a condition to exclude the 'widget' type. Fixes condition that would break this patch when media library with 'permissions denied'.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gauravvvv’s picture

StatusFileSize
new21.93 KB

test only file.

gauravvvv’s picture

StatusFileSize
new1.64 KB
new23.58 KB

I have fixed the CCF in #77, attached a patch and interdiff for same. Please review

Status: Needs review » Needs work

The last submitted patch, 80: 3163299-80.patch, failed testing. View results

larowlan’s picture

StatusFileSize
new21.26 KB

Reroll for 9.5.x

mjpa’s picture

Patch in #82 doesn't work for us, it removes the ajax_view.js changes present in #80.

#80 applied to 9.5.5 cleanly and works for us.

tgauges made their first commit to this issue’s fork.

tgauges’s picture

Changing the target branch of the merge request

  1. broke our build
  2. made the MR have 700+ commits and 1000+ changes

I created a new merge requests against 9.5.x: https://git.drupalcode.org/project/drupal/-/merge_requests/3687.

charly71’s picture

Patch #80 work for us with Drupal 9.5.8 not with 9.5.9
Patch #82 doesn't work at all...

rodrigoaguilera’s picture

Version: 9.5.x-dev » 10.1.x-dev
StatusFileSize
new0 bytes
new1.72 KB

This issue should be fixed first for Drupal 10 and then backport if it applies.

I left some comments in the MR from #90. I think is the right approach.

Since the project where I need this is in Drupal 9.5.9 you can find attached the patch for convenience. The rebase is quite trivial.

rodrigoaguilera’s picture

Status: Needs work » Needs review
StatusFileSize
new24.09 KB

Ugh. Now the non-empty patch

taran2l’s picture

StatusFileSize
new23.82 KB
taran2l’s picture

StatusFileSize
new23.82 KB
taran2l’s picture

StatusFileSize
new23.8 KB

Status: Needs review » Needs work

The last submitted patch, 96: 3163299-96.patch, failed testing. View results

taran2l’s picture

Status: Needs work » Needs review
StatusFileSize
new24.69 KB
taran2l’s picture

StatusFileSize
new24.67 KB
taran2l’s picture

StatusFileSize
new22.96 KB
new5.42 KB
taran2l’s picture

StatusFileSize
new22.93 KB

Status: Needs review » Needs work

The last submitted patch, 101: 3163299-101-D10.patch, failed testing. View results

taran2l’s picture

Status: Needs work » Needs review
StatusFileSize
new23.03 KB
new24.66 KB
new12.83 KB

Arghhh, I think I have found source of the issue why tests are so unreliable, and its #1852090: Cached render elements can have duplicate HTML IDs .. I think the fix is correct, but the test is not due to issues with duplicate form CSS ids.

taran2l’s picture

StatusFileSize
new22.88 KB
new24.6 KB
smustgrave’s picture

Can the issue summary be updated to include the proposed solution and any remaining tasks.

smustgrave’s picture

Status: Needs review » Needs work

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

unstatu’s picture

I have detected that the block preprocess functions are not triggered for the exposed filter blocks when using this patch.

The problem appears because of this file changes

--- a/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php
+++ b/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php
@@ -32,15 +32,17 @@ public function getCacheContexts() {
    *   context of current view and display ID.
    */
   public function build() {
-    $output = $this->view->display_handler->viewExposedFormBlocks() ?? [];
+    $output = [];
+    $build = $this->view->display_handler->viewExposedFormBlocks() ?? [];
     // Provide the context for block build and block view alter hooks.
     // \Drupal\views\Plugin\Block\ViewsBlock::build() adds the same context in
     // \Drupal\views\ViewExecutable::buildRenderable() using
     // \Drupal\views\Plugin\views\display\DisplayPluginBase::buildRenderable().
-    if (!empty($output)) {
+    if (!empty($build)) {
       $output += [
         '#view' => $this->view,
         '#display_id' => $this->displayID,
+        'content' => $build,
       ];
     }

It seems that adding the block render array inside the `content` key avoids to trigger the preprocess functions.

peachez’s picture

StatusFileSize
new22.28 KB

Reroll for D10.2

pyrello changed the visibility of the branch 10.1.x to hidden.

pyrello changed the visibility of the branch 11.x to hidden.

pyrello changed the visibility of the branch 10.3.x to hidden.

liam morland’s picture

There is no need to make a new merge request. You can force-push the branch of the existing merge request and it will use the new code. It will leave behind a tag pointing at the old code.

pyrello’s picture

@Liam Moreland Good to know. Not sure I would have figured that out on my own and I have yet to discover the docs indicating the proper workflow with MRs yet.

ericdsd’s picture

Tested MR from #116 over core 10.3.5 on views embedded with viewsreference + viewsreference_filter + better_exposed_filter with success.
Thanks a lot !

ericdsd’s picture

StatusFileSize
new23.04 KB

Uploading patch from MR 6796 #116 for core 10.3.5

mahmoud barhouma’s picture

patch 120 work for me , thank you

bramdriesen’s picture

I can confirm the latest patch also solved this issue for us.

ericdsd’s picture

Status: Needs work » Reviewed & tested by the community
smustgrave’s picture

Status: Reviewed & tested by the community » Needs work

Issue summary is still incomplete and there are multiple MRs but don’t appear to be one for 11.x

khiminrm’s picture

This patch fixes only views in blocks, but not exposed forms in blocks as in https://www.drupal.org/project/drupal/issues/3032353, right?
Trying to find out how to fix conflicts between patches from both issues and apply to project I'm working on now.

laura.j.johnson@gmail.com made their first commit to this issue’s fork.

ltrain’s picture

The 10.3 patch works to fix the issue with multiple views on a page but we have the issue where exposed filters in media library views break when adding blocks with Layout Builder because there is no ajax applied to them. I have created an MR and attached a patch to use the original form IDs for media library views. We're using Gin LB.

wannesdr changed the visibility of the branch 3163299-views-multiple-ajax-exposed-filters to active.

strykaizer’s picture

@laura.j.johnson@gmail.com

I tried reproducing the media browser issue in vanilla core + layout builder, but I could not reproduce this.
It might be a Gin LB specific issue, which I did not test. If so, gin_lb seems to be the appropriate place to fix this issue.

strykaizer’s picture

We discussed this issue at dev days with Lendude & Wannesdr.

For ajax updates of exposed forms, which is required for e.g. Facets 3 users, we need ajax enabled exposed forms exposed in a block to update the form(s) too.

However, some users' usecase is that they explicitly use "expose form in block" to prevent the form from updating, which is the current behaviour.

That's why we suggest introducing an extra setting, only visible when "expose form in block" is set to "yes", which allows users to choose how the block form should behave (update or do not update on form submit). For existing views, we keep the old behaviour as default value.

strykaizer’s picture

Status: Needs work » Needs review

3163299-views-multiple-ajax-exposed-filters-11.x is a rework of 3163299-views-multiple-ajax-exposed-filters-10.3 which fixes the test and codestyle.

This patch does not include (optional) replacing of the exposed form for e.g. Facets 3.
I'd suggest to keep this patch focussed on replacing the form ID + using a data attribute as selector for AJAX (instead of an ID)
and fix "optionally replace exposed filters in block form" in a follow up.

mxr576’s picture

using a data attribute as selector for AJAX (instead of an ID)

Maybe it worth mentioning that in the latest proposed fix for #3032353: Exposed forms in a block are not updated by AJAX I have introduced a wrapper element around the form that might be also a valid alternative here, although as I wrote in #3032353-63: Exposed forms in a block are not updated by AJAX I do not want to the two issue to become a blocker of each others.

mxr576 changed the visibility of the branch 3163299-ajax-exposed-filters to hidden.

mxr576 changed the visibility of the branch 3163299-ajax-exposed-filters-9.5.x to hidden.

mxr576 changed the visibility of the branch 9.2.x to hidden.

mxr576 changed the visibility of the branch 3163299-views-multiple-ajax-exposed-filters to hidden.

sanderjp’s picture

Patch from current state of MR !11923

_pratik_’s picture

StatusFileSize
new23.02 KB

I found problem with exposed filter on other views after using #120 and #110 patches.
Re rolled and Adding a quick fix in patch.

Thanks

_pratik_’s picture

StatusFileSize
new720 bytes

Here is interdiff between patches 110 and 140
thanks

bramdriesen’s picture

@_pratik_ why update an outdated patch when there is an issue fork with more changes? Why upload a patch when the patch workflow is deprecated?

Update the MR/issue fork if you think your change is relevant.

bramdriesen’s picture

smustgrave’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Hiding patches, closing old MRs

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Rebased as main MR was 600+ commits back, tests are still green

Test coverage is here https://git.drupalcode.org/issue/drupal-3163299/-/jobs/6679875 not posting the output but these failed to match the changes from the MR

Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testExposedBlock with data set "page_display"
Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testExposedBlock with data set "block_display"
Drupal\Tests\views\FunctionalJavascript\BlockExposedFilterAJAXTest::testMultipleExposedFormsForTheSameView
Drupal\Tests\views\Kernel\Plugin\ExposedFormRenderTest::testExposedFormRender

Can vouch that the MR fixes scenario 2.

Don't see any open feedback for this one and believe it's been addressed

Attempted to save credit since last time it was updated.

catch’s picture

Status: Reviewed & tested by the community » Needs work

This needs a rebase unfortunately.

smustgrave’s picture

<<<<<<< HEAD
    this.$exposed_form = $(
      `form.views-exposed-form[data-drupal-target-view="${settings.view_dom_id}"], form.views-exposed-form[data-drupal-target-view="${settings.view_name}-${settings.view_display_id}"]`,
    );
=======
>>>>>>> c2e40edf7410cd3b6a1df898c3e56d3ddd0f08b2

Which came from #343535: Enable bookmarking of AJAX views

I removed it so lets see if it still works.

smustgrave’s picture

I added back the $exposed_form but still appears to be breaking ajax tests so this will need additional work

Seems some tests are failing as the change here is failing to remove empty parameters like 'title='

smustgrave’s picture

Status: Needs work » Needs review

So removing getUniqueId() got all the tests back to green. Want to get a review before RTBC.

mjpa’s picture

surely the getUniqueId() call is needed as the same view multiple times on the page will end up with duplicate IDs?

smustgrave’s picture

That was my thought too so maybe the test case written here wasn’t enough? Because it passes

smustgrave’s picture

Curious if anyone has used the MR after the last bit of changes?

dcam’s picture

Status: Needs review » Needs work

Unfortunately, I have some bad news. I replicated the issue as described in the issue summary. The MR does work to fix it. But the form IDs are duplicated without getUniqueId().

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.