- Issue created by @alison
- πΊπΈUnited States alison
Shoot, I promise I searched around before submitting, but of course I found another issue about this right after I submitted the new one -- so maybe this one I just created is a duplicate?
π Views exposed form action incorrect for embedded views' displays with other displays with paths Needs workI think both issue descriptions have value, I'm not going to take any action yet (other than to make sure I can reproduce it in 10.0.x) -- but I'll comment with my thoughts on the other one.
- π¨π¦Canada adriancid Montreal, Canada
I confirm this problem and there is another situation with this problem if you have AJAX enabled and you have a filter where the user can enter values if an invalid value is entered once you click on the Apply filter button the validation method will show an error. After doing this if you click on the Reset button the page is reloaded and the form is not cleaned and the error validation message is shown again. If you disabled AJAX the Reset button works as expected.
- πͺπΈSpain rodrigoaguilera Barcelona
Ignoring the reset button for ajax is actually intentional for some reason I don't undertand
https://git.drupalcode.org/project/drupal/-/blob/10.0.8/core/modules/vie...
- πΊπΈUnited States maskedjellybean Portland, OR
Good find @rodrigoaguilera. I can't think of a reason for this either. I wonder if simply removing that check would solve the problem and if so would the core maintainers accept it.
- π¬π§United Kingdom iancawthorne
@maskedjellybean I've just given it a try, but if the view is expected to return results with no filters applied, when the reset button is clicked, ajax does fire, but the view shows the empty text instead of the expected results.
- π©πͺGermany Anybody Porta Westfalica
Still an issue. This is especially a problem with the Drupal Media Library Browser for entity reference fields.
When clicking "Reset" in the modal after filtering the media library view , the page reloads and the whole node form is gone!
Seting priority to "Major" accordingly.A similar issue was reported for contrib entity_browser but it's the same root cause: #3173087: Exposed filter reset button close the modal β
- πΊπΈUnited States gslexie
One way to work around this is to override the exposed form template (or maybe form_alter it), replace the clear button entirely with a custom button, and write a Javascript to zero out all form elements and simulate a click of the submit button.
E.G., this is my script. If you have more complex default values then you may need to customize the script for individual views, but at least it works with AJAX.
Drupal.behaviors.CustomClear = {}; Drupal.behaviors.CustomClear.attach = function (context, settings) { const buttons = once('custom-clear', '.views-exposed-form input[type=reset]', context); buttons.forEach(function(element) { const $button = $(element); $button.click(function() { const $form = $(this).closest('.views-exposed-form'); $form.find('input[type=checkbox]').prop("checked", false); $form.find('select, input[type=text]').each(function() { $(this).val(''); }); $form.find('input[type=submit]').click(); }) }) };
- π©πͺGermany Anybody Porta Westfalica
Just ran into this once again. It's now even worse, with Big Pipe and AJAX enabled, the view doesn't load at all any more, once the "
op=X
" parameter is present in the URL!Removing the parameter makes the view re-appear, but it's not cleared.