Views exposed filter reset button not working after data export

Created on 20 January 2023, almost 2 years ago

Problem/Motivation

Views exposed filters reset button does not work if the previous values match with the form values.

Steps to reproduce

Enabled modules

  • Better Exposed filters
  • Views data export

Create a view page/block with

  • Basic config to show content, some exposed filters etc.
  • Exposed form in block = yes
  • Exposed form style = better exposed filters
    • "Include reset button (resets all applied exposed filters)" enabled
    • "Always show reset button" disabled
  • "Use ajax" = yes

Also create data export that is attached the list

  • Path settings
    • Redirect back to the page/block you created
    • "Include query string parameters on redirect" enabled
  • Attach to your page/block
  1. Filter the list using exposed filters
  2. Export the filtered data
  3. Get redirected back to the list, reset button is visible
  4. Click reset button => nothing happens

This seems to be because of core/misc/form.js has

if (previousValues === formValues) {
  e.preventDefault();
} else {
  $form.attr('data-drupal-form-submit-last', formValues);
}

that disables the reset button.

Proposed resolution

The reset button would always reset the filters by reloading the page. The form.js onFormSubmit should detect if reset button is pressed and not prevent submission.

Reading the activeElement data-drupal-selector value one could detect if reset was pressed but that might not work in all browsers. Anyways possible fix could be

if (previousValues === formValues && $(document.activeElement).data('drupal-selector') !== 'edit-reset') {
  e.preventDefault();
} else {
  $form.attr('data-drupal-form-submit-last', formValues);
}

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

-

🐛 Bug report
Status

Active

Version

9.4

Component
Form 

Last updated 2 days ago

Created by

🇫🇮Finland MikaT

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024