Problem/Motivation

Using -1 for the selectedIndex doesn't seem to work all the time. This change seems to work better.

Something like this:

} else if (
          input.tagName === 'SELECT' &&
          !input.hasAttribute('multiple')
        ) {
          // Simple deselect to avoid issue with custom select-based range fields.
          // Range filters currently use "min|max" as value, so the selector
          // based on value cannot be used here.
          // @see https://www.drupal.org/i/3533325
          const empty = Array.from(input.options).find(o => o.value === '');
          if (empty) input.value = '';
          else input.selectedIndex = 0;
          resetInputs.add(input);
        }
CommentFileSizeAuthor
#8 3575799-range-select-does-8.patch15.84 KBgrevil
Command icon 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

brayn7 created an issue. See original summary.

mably’s picture

Status: Active » Needs work
Issue tags: +Needs steps to reproduce, +Needs tests

Hi @brayn7, thanks for your MR.

Could we have a full reproducible scenario from a fresh Drupal 11 instance please?

And it would be great to have this covered by a javascript functional test.

mably’s picture

Status: Needs work » Postponed (maintainer needs more info)

I added a few new JS tests that still seem to work with selectedIndex = -1.

I kept your code searching for empty value but put back selectedIndex to -1 by default for now to avoid breaking things.

We definitely need a reproducible scenario to advance further on this issue.

grevil’s picture

Title: Range select does not get removed when pressing remove filter link » Select does not get reset when pressing the remove filter link on the filter "bubble"
grevil’s picture

Ok, this is fairly hard to reproduce inside a test... Originally I thought, this behavior is easily reproducible by simply setting it up with "views_filters_summary" + "better_exposed_filters", so I added the "ViewsFiltersSummaryBefTest".

But even then, it succeeds without the changes in views-filters-summary.js. So I looked at our original view, and there are even more advanced settings coming from other third party modules.:

Our view filter:

                plugin_id: default
                advanced:
                  sort_options: false
                  sort_options_method: alphabetical_asc
                  sort_options_natural: true
                  rewrite:
                    filter_rewrite_values: ''
                    filter_rewrite_values_key: false
                  collapsible: false
                  collapsible_disable_automatic_open: false
                  open_by_default: false
                  is_secondary: false
                  hide_label: false
                  field_classes: ''
                options_show_only_used: false
                options_show_only_used_filtered: false
                options_hide_when_empty: false
                options_show_items_count: 0

vs. the filter in the test:

                plugin_id: default
                advanced:
                  placeholder_text: ''
                  collapsible: false
                  collapsible_disable_automatic_open: false
                  open_by_default: false
                  is_secondary: false
                  hide_label: false
                  field_classes: ''

I already spent a lot of time on this, since I didn't directly tackle this issue, so I have to cancel here.

TL;DR: I added a proper test and views filter, but the views filter needs further setting exposed from other third party modules to reproduce this issue.

grevil’s picture

Version: 3.4.0-beta1 » 3.x-dev
Status: Postponed (maintainer needs more info) » Needs work

Ok we are also using https://www.drupal.org/project/selective_better_exposed_filters. So it might be a setting related to that. I'll come back to this!

grevil’s picture

StatusFileSize
new15.84 KB

Static patch for the time being.

brayn7’s picture

Sorry for the horrible ticket. @grevil's work does soundly fix my issue. Which when using ajax and facets clicking on a pill to remove a filter did nothing but reload the view with no changes. That was for a single select. Selects with multiple turned on still has the same issue as well even with the new patch.

Additionally the clear filters link doesn't do anything either.

I do think this has to do with compatibility with the facets module potentially.