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
- Filter the list using exposed filters
- Export the filtered data
- Get redirected back to the list, reset button is visible
- 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
-