- Status changed to Needs work
almost 2 years ago 7:01pm 13 February 2023 - šŗšøUnited States smustgrave
Can 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)
- šŗšøUnited States socalerich
I 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. So this is almost certainly an AJAX issue.
- šŗšøUnited States socalerich
I'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:
/* There is currently a bug where if AJAX is enabled for a view and you configure a Reset button to show for exposed filters, the button will not appear when filters are selected. A temp work around is to configure the Reset button to always appear and then this script will initially hide the button, but then show it if there are any query parameters ie: filters have been applied. */ (function ($, Drupal) { Drupal.behaviors.resetFilters = { attach: function (context, settings) { $(".form-submit[id^=edit-reset]").hide(); if (window.location.search) { $(".form-submit[id^=edit-reset]").show(); } }, }; })(jQuery, Drupal);
- šŗš¦Ukraine TŠ°o
quick solution with hook_form_alter()
$form['buttons'] = $form['actions']; unset($form['actions']);
But it really needs to be fixed.
- šŗšøUnited States jayhuskins
I 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
- Keep the reset button in the form, but do not use it with AJAX.
- Keep the reset button in the AJAX form and fix the "Many things" that will subsequently break
- š®š³India adwivedi008
Is 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
- šŗšøUnited States sea2709 Texas
I 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.
- š·š“Romania dorutirlea
The 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 āØ Exposed forms in a block are not currently updated when Ajax filtering is executed Needs work , will fix the show/hide reset button problem as well.
- š·š“Romania dorutirlea
The 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 āØ Exposed forms in a block are not currently updated when Ajax filtering is executed Needs work , will fix the show/hide reset button problem as well.
Enjoy