Allow the user to reset the range slider

Created on 24 March 2021, over 3 years ago
Updated 20 February 2024, 7 months ago

Problem/Motivation

There is no way to reset a range slider after using it for the first time.

Depending on the configuration on min/max values, this result on two scenarios, both of them troubling for the user:

In the case of 'search_result' min/max, this means the user is only able to "narrow" the selection and can never go back (widen) the selection. This has also been reported on this issue

In the case of "fixed" min and max values, when a user intent is to "reset" a range slider by repositioning the min/max handles on the min/max values, the query params remain still set and this can lead to unexpected behaviors if the user was expecting to "reset" the facet completely (meaning don't apply the facet at all).

In both cases there is no UI for resetting all values.

Steps to reproduce

Generally speaking, once we use the range slider, we don't have a way to "unset" it. If we use the 'search_result' for min/max values, we don't have even a way to "go back" on our selection.

This can lead to unexpected exclusion of the search index elements that don't have any value for the numeric field.

Consider the following scenario:

- A numeric indexed field.
- There are 10 indexed elements that have a value for the numeric field (from 1 to 10), and one that does not. In total, we have 11 indexed elements.
- A range slider with a fixed min of 0 and a fixed max of 10.

When we land on the search, the slider handles are positioned on 0 and 10 and we see (all) 11 results.

If we move the handles and position them on 5 and 8, we see four results (5, 6, 7, 8).

If we move back the handles to 0 and 10, we see 10 results instead of 11; even if the position is visually equal to the starting point, we are missing one result. This is because when the handles coincide with the min-max values, the query parameters will be still set to those values.

This can be felt as a "bug" by the user or the user might realize what's happening and still will be missing a "reset" button

Proposed resolution

The Range Slider facet could provide a 'reset_url' value on drupalSettings. This reset url will keep all existing query parameters except from the range slider ones.

This value can be used then the client-side to expose some way for the user to reset the slider.

- A button or action link.
- Automatically, on 'fixed' min/max, when the user repositions the handles on the min/max positions.

Remaining tasks

Test

User interface changes

A pair of checkboxes have been exposed on the Range Slider Settings with the following info:

[ ] Remove facet on minmax reset
Removes this facet filter when the user reposition the handles on both the min and max values. Only valiw with fixed min and max
values.

[ ] Show reset action

API changes

- Added a 'reset_url' value to the drupalSettings exposed to the facet that includes the target URL (as a string)
- Added a 'minmax_reset' boolean field to the range slider configuration schema and form
- Added a 'reset' boolean field to the range slider configuration schema and form

Data model changes

Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

🇪🇸Spain idiaz.roncero Madrid

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • 🇩🇰Denmark ressa Copenhagen

    Thank you very much for building this @idiaz.roncero. So it works, but only tests are missing?

    @james.williams: It does look like the reset function could be added in Slider instead, since RangeSliderWidget extends SliderWidget ... If it was added in Slider, would it not then be available for both "Slider" as well as "Range slider"?

  • 🇩🇰Denmark ressa Copenhagen

    Changing version to 2.0.x, since I can't create a new branch with 3.0.x ...

  • 🇩🇰Denmark ressa Copenhagen

    No luck, I am getting this message, after clicking "Create new branch":

    Failed to create branch '3205381-allow-the-user-2x': invalid reference name '2.0.x'

    It looks like it's not possible via Gitlab GUI, but using Git via command line is necessary:

    Pulling in new branches from an issue fork's parent

  • 🇩🇰Denmark ressa Copenhagen

    Fix "Added a 'eset' boolean field" to reset in issue Summary :)

  • 🇩🇰Denmark ressa Copenhagen

    The patch applies against 2.0.x-dev (with a single offset) and works well. I get a working "reset"option, after enabling it.

    Disregard my comment about building it for standard Slider in #13. I actually only need it for Range Slider, and the current patch works well for this.

  • 🇩🇰Denmark ressa Copenhagen

    Would it be possible to add an upgrade path for existing facets? Because it looks like the patch doesn't take effect on already existing facets ... Reinstalling and reconfiguring the facets is not that big a task, so it's not a big deal, more like a nice to have.

Production build 0.71.5 2024