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
-
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3335209.patch | 983 bytes | mikat |
| #4 | interdiff_2-4.txt | 1.21 KB | _utsavsharma |
| #4 | 3335209-4.patch | 1.21 KB | _utsavsharma |
| #5 | 3335209.patch | 1.56 KB | mikat |
| #8 | interdiff_5-8.txt | 1.74 KB | _utsavsharma |
Issue fork drupal-3335209
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
Comment #2
mikat commentedComment #3
cilefen commentedI am moving this to the bug fix branch and setting it for review.
Comment #4
_utsavsharma commentedTried to fix CCF for #2.
Comment #5
mikat commented9.4 patch with updated form.es6.js
Comment #6
mikat commentedComment #7
mikat commentedChanges version to 9.4.x.
Comment #8
_utsavsharma commentedFixed CCF for #5.
Comment #9
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #10
_utsavsharma commentedpatch for 10.1.x.
Comment #11
cilefen commentedLet's put this back on the bug fix branch. Drupal 9.4 does not get bug fix releases any more (only security). Patches for 9.4.x will not be committed.
Comment #12
kemsnake commentedUploaded patch for 9.5.x
Comment #13
suresh prabhu parkala commentedRe-rolled patch against latest 9.5.x. Please review.
Comment #15
anybody