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:

  1. Views
  2. Views UI
  3. Chaos Tools Views
  4. Metatag: Views
  5. Simple XML Sitemap (Views)
  6. Slick Views
  7. Views Contextual Filter Default Entity Field Values

The last two were installed after I found this bug.

Steps:

  1. Create View
  2. Add filters and expose them
  3. Exposed form in block: Yes
  4. Exposed form style: Basic
  5. In form settings " Include reset button" is checked
  6. Use AJAX: Yes
  7. Place the filter block on a view page
  8. Go to your view page, make changes to form, view changes, Reset button doesn't show up.
  9. 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 )))

Pending

Remaining tasks

Code / Review / Commit

User interface changes

Pending

API changes

None

Data model changes

None

Release notes snippet

Issue fork drupal-3246142

Command icon 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

bigboy created an issue. See original summary.

timme77’s picture

Same problem here, did you find a solution for this?

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jane_irwin’s picture

Seeing the same issue. Any suggestions?

lucuhb’s picture

Same issue here, is there any solution for this ?

Muttecht’s picture

I'm experiencing this also. Reset button worked fine in my View Page, but when used as a block it doesn't render.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

rhrueda’s picture

I am still experiencing this issue. Has anybody solved it?
Thank you.

raveen_thakur51’s picture

Status: Active » Needs review

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

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update

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)

erichhaemmerle’s picture

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.

erichhaemmerle’s picture

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) {
      $resetButton = $(".form-submit[id^=edit-reset]");
      $resetButton.hide();
      if (window.location.search) {
        $resetButton.show();
        $resetButton.on("click keypress", function (e) {
          e.preventDefault();
          location.href = location.origin + location.pathname;
        });
      }
    },
  };
})(jQuery, Drupal);

tаo’s picture

quick solution with hook_form_alter() and Better Exposed Filters

    $form['buttons'] = $form['actions'];
    unset($form['actions']);

But it really needs to be fixed.

jayhuskins’s picture

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

  1. Keep the reset button in the form, but do not use it with AJAX.
  2. Keep the reset button in the AJAX form and fix the "Many things" that will subsequently break
shweta__sharma’s picture

Issue summary: View changes

Added IS template and updated minor changes.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

adwivedi008’s picture

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

sea2709’s picture

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.

dorutirlea’s picture

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, will fix the show/hide reset button problem as well.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.