Problem/Motivation
Drupal 9.2.7. All modules have latest versions.
The reset button is not even loaded to DOM when using exposed filters form in a block with Ajax enabled.
There are no errors in the console.
Related issue - https://www.drupal.org/project/better_exposed_filters/issues/3232707
But it was addressed to Better Exposed Filter module, which I'm not using.
So I guess it's a core bug.
Steps to reproduce
Modules, that use Views:
- Views
- Views UI
- Chaos Tools Views
- Metatag: Views
- Simple XML Sitemap (Views)
- Slick Views
- Views Contextual Filter Default Entity Field Values
The last two were installed after I found this bug.
Steps:
- Create View
- Add filters and expose them
- Exposed form in block: Yes
- Exposed form style: Basic
- In form settings " Include reset button" is checked
- Use AJAX: Yes
- Place the filter block on a view page
- Go to your view page, make changes to form, view changes, Reset button doesn't show up.
- But if you go to /view-page?field_name_value=something - Reset button is displayed.
If "Exposed form in block" is NO, then the Reset button is there, as expected. When I click on it it doesn't use ajax and redirects to /view-page/All, but there is another issue for that already.
Proposed resolution
Make it work )))
Merge request link
Pending
Remaining tasks
Code / Review / Commit
User interface changes
Pending
API changes
None
Data model changes
None
Release notes snippet
Issue fork drupal-3246142
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
Comment #2
timme77 commentedSame problem here, did you find a solution for this?
Comment #4
jane_irwinSeeing the same issue. Any suggestions?
Comment #5
lucuhb commentedSame issue here, is there any solution for this ?
Comment #6
Muttecht commentedI'm experiencing this also. Reset button worked fine in my View Page, but when used as a block it doesn't render.
Comment #9
rhrueda commentedI am still experiencing this issue. Has anybody solved it?
Thank you.
Comment #10
raveen_thakur51 commentedThe same error is showing up for me when I am using Basic filters. But the reset button appears when I search for something in the search box. We have the option for reset button if we use better exposed filters. Then the reset button is added in the view.
Comment #11
smustgrave commentedCan confirm the issue in D10
Moving to NW as there was no patch.
Issue summary will have to be updated with before/after screenshots with fix. Also proposed solution (when one is figured out)
Comment #12
erichhaemmerle commentedI am experiencing the same thing. As a side note, I am using the Views AJAX History module which, even when using AJAX, it will add the search criteria query params to the browser URL so you can preserve deep linking. When this is added and you do your initial search by, in my case, choosing a checkbox that filters the results, I initially do not see the reset button, but if I immediately refresh the page with the query parameters in the URL, the reset button appears.
Comment #13
erichhaemmerle commentedI'm not sure if this will help anyone else, but I have come up with a temporary work around for this. It's a little hackey, but it is working for me. The prerequisite though is that you have the Better Exposed Filters module and the Views AJAX History module installed and have your view setup to use AJAX History, which can be enabled in the AJAX settings of your view. This will essentially add URL parameters to the URL with your filters even though you are using AJAX. This is actually a plus as far as I am concerned, because it enables bookmarking of filters that were applied to your search. Other than that, just set your Reset button to "Always display" in the BEF settings. Then use this JavaScript:
Comment #14
tаo commentedquick solution with hook_form_alter() and Better Exposed Filters
But it really needs to be fixed.
Comment #15
jayhuskinsI think I found where the behavior is coming from:
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/views...
Here the reset button is explicitly ignored from the ajax form because "Many things break during the form reset phase if using AJAX". There are two options for moving forward on this issue
Comment #16
shweta__sharma commentedAdded IS template and updated minor changes.
Comment #18
adwivedi008 commentedIs there any update on this issue? This is an issue if we are using Ajax and a better-exposed filter together
Any workaround would also be appreciated
Comment #19
sea2709 commentedI found a workaround solution based on this article https://www.drupal.org/forum/support/post-installation/2018-02-28/how-to...
Whenever a user clicks on the reset button in an ajax view, I trigger the event RefreshView on that view.
Comment #20
dorutirlea commentedThe patch applied for field updates issue on exposed form in block, that you can find here https://www.drupal.org/project/drupal/issues/3032353#comment-15746970, will fix the show/hide reset button problem as well.