Exposed filters get values from url when ajax is on

Created on 20 March 2020, about 5 years ago
Updated 6 December 2022, over 2 years ago

When view has ajax on and page url has some parameters what are exposed filters (view page with some applied filter values) if uncheck selected filters and submit exposed form looks view is still filtered by the value from url.

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Viewsย  โ†’

Last updated about 1 hour ago

Created by

๐Ÿ‡บ๐Ÿ‡ฆUkraine myha

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • last update almost 2 years ago
    29,201 pass, 26 fail
  • last update almost 2 years ago
    Patch Failed to Apply
  • Status changed to Needs review almost 2 years ago
  • last update almost 2 years ago
    Patch Failed to Apply
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States AaronBauman Philadelphia

    None of these patches work against drupal ^10.1 or ^11

    Here's a re-roll

  • last update almost 2 years ago
    29,531 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States AaronBauman Philadelphia

    And fix the path

  • last update almost 2 years ago
    Patch Failed to Apply
  • last update almost 2 years ago
    29,436 pass
  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Was previously tagged for tests which still appear to be needed.

    And issue summary could use some attention.

    Thanks

  • First commit to issue fork.
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    This patch seems to break โœจ Enable bookmarking of AJAX views Needs work when both are applied.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States AaronBauman Philadelphia

    AaronBauman โ†’ changed the visibility of the branch 3121172-exposed-filters-url to hidden.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States AaronBauman Philadelphia

    Re-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.

  • last update about 1 year ago
    Patch Failed to Apply
  • ๐Ÿ‡ช๐Ÿ‡ธSpain akalam

    Patch 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.

  • ๐Ÿ‡ง๐Ÿ‡ทBrazil joaopauloc.dev

    patch #29 worked for me, Drupal 10.2.6m thanks!

  • ๐Ÿ‡ช๐Ÿ‡ธSpain unstatu

    I 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.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain unstatu

    I messed up with the paths.

    This version has the same code but with the correct paths.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain akalam

    Patch #32 is using "this" instead of "that" in a context where this is the windows object. Here's a patch fixing it

  • ๐Ÿ‡ง๐Ÿ‡พBelarus gun_dose

    Patch #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.

  • ๐Ÿ‡ท๐Ÿ‡ดRomania andreic

    The only patch version that work 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.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada gordonio

    I ran into the same issue as #31 with the opener_id error. 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

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    prudloff โ†’ changed the visibility of the branch 10.0.x to hidden.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    prudloff โ†’ changed the visibility of the branch 11.x to hidden.

  • Merge request !10230Apply patch from comment #34 โ†’ (Open) created by prudloff
  • Pipeline finished with Failed
    5 months ago
    Total: 86s
    #342415
  • First commit to issue fork.
  • Pipeline finished with Failed
    5 months ago
    Total: 85s
    #342570
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom oily Greater London

    Tried to fix Javascript lint. Search and replaced $exposed_form with camelcase $exposedForm. Reduced lint errors from 20 to 18.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia niranjan_panem Gurugram

    Tested 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.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    This will get more visible if โœจ Enable bookmarking of AJAX views Needs work 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.

  • Pipeline finished with Failed
    18 days ago
    Total: 1001s
    #449241
  • Pipeline finished with Failed
    18 days ago
    #449257
  • Pipeline finished with Success
    18 days ago
    Total: 1179s
    #449264
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    I added a test that shows the problem.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    I tried reverting the camel case changes locally but it makes yarn run lint:core-js-passing complain:

    /media/pierre/Projets/workspace/drupal-core/core/modules/views/js/ajax_view.js
      176:20  error  Identifier '$exposed_form' is not in camel case  camelcase
      182:5   error  Insert `ยทยท`                                      prettier/prettier
      182:5   error  Identifier '$exposed_form' is not in camel case  camelcase
    
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Hiding patches and closing old MRs

    Following the steps I get a request like

    https://drupal-11x.ddev.site/views/ajax?status=All&title=&type=All&_wrapper_format=drupal_ajax&title=&type=All&status=All&view_name=content&view_display_id=page_1&view_args=&view_path=%2Fadmin%2Fcontent&view_base_path=admin%2Fcontent&view_dom_id=163f73bb84d4e170f0b939de25d6c337ec0daf0d5e472897f73c099a6e1eb94f&pager_element=0&_drupal_ajax=1&ajax_page_state%5Btheme%5D=claro&ajax_page_state%5Btheme_token%5D=U8_NBi2POrE9U1ELs8h7ziadng1Svy8k__iIvXtLat0&ajax_page_state%5Blibraries%5D=eJx9j20OwjAIhi_UbWfwJIZ2ZKuy0gCdH6e36hqjS_zTwMMDeevjdMwx4-C3wgUC4WGUkoH6BGtn4HWjE7EH6tRuFNPkAifDqxWg5n9IV42z_leMmTxIlQTbGILFFV_bX7ymIJwRRpQ9F9TMSevifqZIGOzNE8sCFO_odGaxUKyprXdbpqFl--l71AAZD-MSkyuK0g486z7Wz6lbI150eL09nOD6BRYeC-EDDheR7w
    

    After applying the MR

    I get

    https://drupal-11x.ddev.site/views/ajax?_wrapper_format=drupal_ajax&title=&type=All&status=All&view_name=content&view_display_id=page_1&view_args=&view_path=%2Fadmin%2Fcontent&view_base_path=admin%2Fcontent&view_dom_id=6bd75558a30df1be7b7f74ebc9fc473a68a2dc3c5e496a831679f7aed2d7155a&pager_element=0&_drupal_ajax=1&ajax_page_state%5Btheme%5D=claro&ajax_page_state%5Btheme_token%5D=U8_NBi2POrE9U1ELs8h7ziadng1Svy8k__iIvXtLat0&ajax_page_state%5Blibraries%5D=eJx9j20OwjAIhi_UbWfwJIZ2ZKuy0gCdH6e36hqjS_zTwMMDeevjdMwx4-C3wgUC4WGUkoH6BGtn4HWjE7EH6tRuFNPkAifDqxWg5n9IV42z_leMmTxIlQTbGILFFV_bX7ymIJwRRpQ9F9TMSevifqZIGOzNE8sCFO_odGaxUKyprXdbpqFl--l71AAZD-MSkyuK0g486z7Wz6lbI150eL09nOD6BRYeC-EDDheR7w
    

    Not the best with nightwatch review and test-only pipeline doesn't work with nightwatch But

    browser.assert.strictEqual(
                  url.searchParams.getAll('title').length,
                  1,
                  'Duplicate title parameter',
                );
    

    Should show the duplicates so believe it's valid coverage

    Going to mark.

  • Pipeline finished with Success
    2 days ago
    Total: 454s
    #461870
Production build 0.71.5 2024