Needs work
Project:
Drupal core
Version:
main
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Mar 2020 at 13:13 UTC
Updated:
4 Sep 2026 at 03:38 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
myha commentedHere is my solution to fix this: check query url parameters and remove from there all exposed filter parameters because them should be passed in POST parameters.
Comment #3
cilefen commentedComment #5
mupsiHey, here is an update of myha's patch for 8.9.x. It works for me, thanks!
Comment #6
ironsizide commentedThe patch in #5 works well for me.
Comment #7
aaronbaumanLGTM
Comment #8
catchThis needs some test coverage.
Comment #9
the.tai.pen@gmail.com commentedI had the same issue and patch #5 solved it for me.
Comment #10
greenskin commentedFunctionality LGTM.
Comment #12
claudiu.cristeaYes, #5 seems to do it. However, after submitting an exposed filter change, I see the views results and exposed filter being out-of-sync with the URL displayed in browser. Shouldn't JS update also the URL in the browser's address bar? For instance, I'm doing a filtering using the exposed form, then I want to share this search with a colleague but I'm sending them a wrong URL. Maybe this needs some usability input? I'm tagging with "Needs usability review" to get some guidance on the expected behavior.
Comment #14
claudiu.cristeaTried to write a test but I cannot replicate the error. @myha, could provide steps to replicate the bug as a test?
However, I still need #12. I'll move that part to #343535: Enable bookmarking of AJAX views
Comment #15
rajab natshahUpdated the patch to work with Drupal 9.3.x and 9.4.x
Only for the process of upgrading from Drupal 8 to Drupal 9
Comment #16
ravi.shankar commentedFixed Drupal CS issue of patch #15.
Comment #17
prudloff commentedI have a similar issue but with pages. If the page query parameter is set, then it is used in ViewAjaxController even though it is not in the POST data.
This creates weird behaviors, for example sending users to a page that does not exist for the current set of selected exposed filters.
Comment #20
pasqualleThanks for the patch. Works great.
Comment #22
aaronbaumanNone of these patches work against drupal ^10.1 or ^11
Here's a re-roll
Comment #23
aaronbaumanAnd fix the path
Comment #24
smustgrave commentedWas previously tagged for tests which still appear to be needed.
And issue summary could use some attention.
Thanks
Comment #26
prudloff commentedThis patch seems to break #343535: Enable bookmarking of AJAX views when both are applied.
Comment #28
aaronbaumanRe-rolled against 11.x and 10.2.x
Still working for me, still needs tests
hiding MR 1484 to minimize noise, but please unhide if someone wants to untangle it.
Comment #29
akalam commentedPatch on #28 didn't work for me using facets v3.
I'm uploading a new patch using a simpler solution, skip url querystring on the settings object being passed to the ajax method on javascript. By this way, all the input from the form is being sent, but the querystring is not, so no override on parameters is raising the server.
Comment #30
joaopauloc.dev commentedpatch #29 worked for me, Drupal 10.2.6 thanks!
Comment #31
unstatu commentedI have improved the approach taken by #29 in order to only remove the inputs existing in the exposed form from the URL used by AJAX.
I did this because I found a problem using the media library with this patch applied. The steps to reproduce the problem are the following :
- Open the media library modal of a field widget
- Use the exposed form in the media library modal and send the form to filter the results
- Select any media and click insert
- You will get the following error: "The opener ID parameter is required and must be a string."
This happens because the patch in #29 is removing the query parameters required by the media library (in addition to the ones present in the exposed form) when the AJAX call is done.
Comment #32
unstatu commentedI messed up with the paths.
This version has the same code but with the correct paths.
Comment #33
akalam commentedPatch #32 is using "this" instead of "that" in a context where this is the windows object. Here's a patch fixing it
Comment #34
gun_dose commentedPatch #33 has some issues for me. It operates with form values, so if I have some value in URL, uncheck it, apply filters and then check other value, both values appears checked, because form data doesn't contain value key if all options are unchecked. Also in my case I have multiple values for my filter, so in URL it appears as manufacturer[0], manufacturer[1] etc. And in form adata it appearc as manufacturer[] (with empty brakes). To handle this I splitted filter names by openig square brake and now it works for me.
Comment #35
andreic commentedThe only patch version that works for me in 10.2.6 was the one in #34. However, it fixes only the tag filtering, those are respected now but the problem is results are no longer returned.
Comment #36
gordonio commentedI ran into the same issue as #31 with the opener_id error when trying to use media library items after using the views exposed filters to search for something. The patch in #34 seems to be working fine for me and I haven't noticed any issues with filtering so far.
Core Version 10.2.6
Comment #41
ironnuts commentedTried to fix Javascript lint. Search and replaced $exposed_form with camelcase $exposedForm. Reduced lint errors from 20 to 18.
Comment #42
niranjan_panem commentedTested it in drupal 11 with below description.
1. created a view
2. created the filter of authored on field and exposed it
3. tested the filter field with before adding ajax to exposed form.
4. tested the filter field with after adding ajax to exposed form.
Before adding ajax, filter parameters are taken from url and giving expected output.
After adding ajax, filter parameters which still exist in url are not taken to get results.
It is working as expected.
Below is the screen shot of before adding ajax.
Below is the screen shot of after adding ajax.
Comment #43
prudloff commentedThis will get more visible if #343535: Enable bookmarking of AJAX views is merged, because then a lot more AJAX requests will be made with existing GET parameters in the URL.
I will try to find a way to show this in a test.
Comment #44
prudloff commentedI added a test that shows the problem.
Comment #45
prudloff commentedI tried reverting the camel case changes locally but it makes
yarn run lint:core-js-passingcomplain:Comment #47
smustgrave commentedHiding patches and closing old MRs
Following the steps I get a request like
After applying the MR
I get
Not the best with nightwatch review and test-only pipeline doesn't work with nightwatch But
Should show the duplicates so believe it's valid coverage
Going to mark.
Comment #48
nod_had a comment on the MR waiting for several weeks, sorry about that
Comment #50
carolpettirossi commentedThis issue also manifests in the Media Library modal when using exposed filters with multi-value select fields (e.g. a folder/directory filter).
Steps to reproduce with Media Library:
What happens in the payload:
The directory[] filter values were being sent three times - once from the accumulated URL query string embedded in view_query, once from the serialized form data, and then the new selection appended at the end. The result was that old selections were never cleared.
Before and After patch videos attaches for reference.
Confirmed working on Drupal 10.5.6 with the Media Library widget.
Comment #51
prudloff commentedNow that #343535: Enable bookmarking of AJAX views has been committed, this bug basically breaks AJAX exposed filters after the first submit so we should really get this fixed.
Comment #52
smustgrave commentedFact some tests had to be updated to pass makes me worried this will be a BC for contrib tests.
Comment #53
prudloff commentedThe order of the parameters in PaginationAJAXTest was changed by #343535: Enable bookmarking of AJAX views: https://git.drupalcode.org/project/drupal/-/commit/9c8eb293cae3114a76b95...
This MR reverts to the previous order. (It is a side effect, but you could say it fixes the BC break from #343535: Enable bookmarking of AJAX views.)
Comment #54
smustgrave commentedGood to know! Left a comment on the test though.
Comment #55
smustgrave commentedMaybe a test in ExposedFilterAJAXTest can be expanded?
Comment #56
mialdi98 commentedRolling patch (without tests) for Drupal 11.3 if someone is updating their site and getting composer errors
from https://git.drupalcode.org/project/drupal/-/merge_requests/10230/diffs (#34)
Comment #57
acbramley commentedThis looks like it could be a duplicate of #3273334: Unable to unselect a multi select exposed filter in ajax view