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