Remove link removes all filters

Created on 2 March 2023, almost 2 years ago

Problem/Motivation

When a page has query params, such as when a view is not using Ajax or using Ajax with the Views Ajax History module, the individual remove links reset all filters instead of removing the single filter.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States pixelwhip

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

Merge Requests

Comments & Activities

  • Issue created by @pixelwhip
  • 🇺🇸United States pixelwhip

    I've tested this merge request on a view that had single value and multi-value filters, with no Ajax, core Ajax and Ajax with Views Ajax History. It resolved the issues for me.

  • Status changed to Needs review almost 2 years ago
  • 🇺🇸United States COBadger

    In my testing of this patch, clicking on the "x" for one of the filters caused the page to reload and the other filter values were lost in the reload.

    In my use case the view is added to the page in the page template via lazy views.

  • 🇺🇦Ukraine khiminrm

    Tested the fixes from the MR. They didn't work for me. The page was just reloaded.
    I've found that for multiple value filter the search arguments can have such structure:
    ?geography_type[region]=region&geography_type[country]=country
    So I've added such lines:

              // Remove keyed element.
              url.searchParams.delete(`${selector}[${value}]`);
    

    It helped to fix the remove links I tested.
    Attaching the patch.

  • 🇺🇸United States attheshow

    It looks like neither of the previous patches are applying cleanly to version 2.0.0-alpha3 that was just released this week.

  • 🇮🇳India JaydipJD surat

    I have re-rolled the patch for 2.0.0-alpha3

  • 🇧🇪Belgium leanderjcc Ghent

    Patch from #8 applied and solved the issue for us on a view without AJAX (2.0.0-alpha3).

  • 🇺🇸United States spais

    Confirming patch #8 works on a view without AJAX.

  • Pipeline finished with Success
    9 months ago
    Total: 148s
    #130073
  • 🇺🇸United States pixelwhip

    The original merge request has been updated to include the latest changes from #8 it also reintroduces support for multi-value filters that are formatted as ?filtername[]=foo&filtername[]=bar. This was removed in patch #6. It seems multi-value filters can have different formats in the url search params.

  • 🇺🇦Ukraine khiminrm

    When there are multiple exposed forms from the different views on one page this
    $('.views-exposed-form input[type="submit"]:nth-child(1)').trigger('click');
    doesn't work.
    We need to use some additional attributes by which we can find correct exposed form and submit it.

  • 🇺🇦Ukraine khiminrm

    I've updated the MR to fix the issue described in #12.

  • Pipeline finished with Success
    6 months ago
    Total: 179s
    #214088
  • 🇺🇦Ukraine khiminrm

    created patch from the current MR

  • 🇺🇦Ukraine khiminrm

    I've noticed similar bug described there https://www.drupal.org/project/views_filters_summary/issues/3378822 🐛 Alter means of testing if a view is ajax-enabled Needs review . I had destination parameter in URL and the page was reload on clicking links in the filters summary. So I've updated javascript and added some more specific selectors for the submit buttons:

  • Pipeline finished with Success
    4 months ago
    Total: 200s
    #267182
  • 🇱🇧Lebanon christina_abboud

    Hello,

    I had the same issue and I created this patch to fix it

    • mably committed 4f531fac on 3.0.x
      Issue #3345403 by khiminrm, pixelwhip, christina_abboud, jaydip makawana...
  • Assigned to mably
  • Status changed to Fixed 3 months ago
  • 🇫🇷France mably

    Should be fixed in 3.0.x-dev branch.

    Thanks for all you contributions!

  • 🇺🇦Ukraine khiminrm

    I see that committed fixes don't include fixes to get correct exposed to submit in case when there are multiple exposed form blocks from different views on one page. I mentioned about it in https://www.drupal.org/project/views_filters_summary/issues/3345403#comm... 🐛 Remove link removes all filters Fixed and added some additional code changes to fix it. So in current dev version we potentially can face with the same issue.

  • Status changed to Needs work 3 months ago
  • 🇫🇷France mably

    @khiminrm I'll have a look at it, thanks 👍

  • 🇺🇦Ukraine khiminrm

    @mably thanks!

    In our case we're using exposed form block with autocomplete search from one view in header of a site and another exposed form block in sidebar region on the views page (another one view). So there are two different exposed form blocks on one page. I know that there can be rare cases when on one page we can have even multiple exposed forms for the same view e.g. to show some filters above the view's results and other filters in sidebar etc.

    • mably committed 44a0cf50 on 3.0.x
      Issue #3345403 by khiminrm, pixelwhip, jaydip makawana, christina_abboud...
  • Status changed to Fixed 3 months ago
  • 🇫🇷France mably

    @khiminrm this last commit^^ should fix it.

  • 🇺🇦Ukraine khiminrm

    @mably thanks a lot for adding these fixes! sorry I can't re-test it right now. I hope it will work as expected. Thanks again!

  • 🇫🇷France mably

    You're welcome! Feel free to come back to me if you encounter any issue.

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

  • Issue was unassigned.
Production build 0.71.5 2024