When using 'Exposed form in block' with Ajax enabled the 'Reset' button is never shown, so it's not possible to reset the filter selections.

Comments

Stephen Ollman created an issue. See original summary.

lendude’s picture

Didn't try to reproduce but #2732111: Reset button doesn't work and never gets removed on AJAX enabled views should give a nice indication where we could add some tests for this.

lestat’s picture

Issue tags: +Dublin2016

Checking this issue DrupalCon Dublin.

Leagnus’s picture

Confirm the issue on Drupal 8.5.x-dev and PHP v.7.0.11.
Workaround is

$(document).ajaxComplete(function( event, xhr, settings ) {
        if (!$(".exposed_form_reset").length){
            $("[id^='views-exposed-form']").find('#edit-actions').append('<button onclick="javascript:jQuery(this.form).clearForm();jQuery(this.form).find(\'.form-submit\').trigger(\'click\');return false;" class="exposed_form_reset">' + Drupal.t('Reset') + '</button>');
        }
    });
ippy’s picture

Yep, I can confirm that Leagnus's simple workaround will do the trick (D8.6 + PHP 7).
Needs targeting to your own form and submit ids obviously.

andreynacarrasco’s picture

Sorry for my ignorance (and my english...) but, where do I implement @Leagnus´s workaround?

socialnicheguru’s picture

There is no reset button if a view is using ajax either.

How can this fix be implemented? Is it in a custom module?

ippy’s picture

Better late than never I suppose...

I think I achieved this by way of the following (or some combination thereof - sorry, its a while ago now. Probably this: https://www.drupal.org/docs/8/theming/adding-stylesheets-css-and-javascr... as we only use it on this one page):

  • ***.theme (adds a function to attach the rl-ajax.js to a specific page)
  • ***.info.yml (includes the new library ***/rl)
  • ***.libraries.yml (defines the library)
  • rl-ajax.js (contains my primitive jstuff, including the reset button business. Also updates returned results count)

Can be seen functioning here: https://bridge47.org/resources - search for anything that yields results in order to get the reset button dynamically attached via the extra js that is called for this page.

Basically add the js in a file, make it available to the theme and then call it on whatever page/s you need it.

Version: 8.2.0-rc1 » 8.2.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.2.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

colan’s picture

Title: No Reset button with Exposed Block using AJAX » Support "Use AJAX" behaviour on "Reset" button in views

Copied title from #3063267: Support "Use AJAX" behaviour on "Reset" button in views, which I've marked as a duplicate. As mentioned over there, and in #7, this isn't specific to exposed blocks.

Here's the only useful comment from over there:

Code changes in #2024695-8: The "Reset" button ignores the "Use AJAX" setting (always behaves in a non-AJAX way). was reverted in #2732111-33: Reset button doesn't work and never gets removed on AJAX enabled views due to a lot of things getting broke[n] during the form reset phase.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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.

smustgrave’s picture

Status: Active » Closed (cannot reproduce)
Issue tags: +Bug Smash Initiative

Going to close as can't reproduce

I tested by enabling ajax on the admin/content view
Filtered by a string
Verified reset button appears and is functional

If this is still an issue please reopen and provide an updated IS.

siramsay’s picture

@smustgrave

I can reproduce this. You need to use the Exposed form setting Exposed form in block and set it to Yes.

Then place the exposed from using block placement or in code.

jayhuskins’s picture

Status: Closed (cannot reproduce) » Closed (duplicate)
Related issues: +#3246142: Reset button is not displaying in Exposed filter block when using Ajax

Marking this as a duplicate of issue #3246142