appbaseio / reactivesearch

Search UI components for React and Vue
https://opensource.appbase.io/reactivesearch
Apache License 2.0
4.89k stars 471 forks source link

Do not apply pristine range filters #1059

Open joepio opened 4 years ago

joepio commented 4 years ago

Affected Projects React

Library Version: x.y.z 3.0.0-rc.20

Describe the bug When filtering sparse data (i.e., when some of the attributes can be present, but may not be), you want filter components to only be applied when the user explicitly sets them.

For example: I work on a search app that filters by some date field, but that date field is only present in 40% of the documents. When I render the RangeSlider component, only items are shown that contain some value for the dataField attribute. This means that only documents are shown that have that specific date field.

This happens, because the RangeSlider applies a filter to the query with the range start and end values.

Ideally, this filter is only applied after the user interacts with the component. This could be fixed by adding a pristine state to RangeSlider and others, and only applies the filter when its value is false.

Perhaps this could be set as an optional prop, e.g. ignoreUntouched.

bietkul commented 4 years ago

Related #739

janus-reith commented 4 years ago

Actually I think this is not fixed completely. While the mechanics implemented with the includeNullValues prop are necessary to get the desired behaviour, a typical solution should be to have something like the ignoreUntouched prop which @joepio proposed.

The component could then set includeNullValues to true internally as long as it is not selected, and turn it to false as soon as there has been user interaction.

In https://github.com/appbaseio/reactivesearch/issues/1096 I suggested that there could be visual indication aswell, like greyed out handles for the initial state.

joepio commented 4 years ago

I agree with @janus-reith, the includeNullValues prop does not solve this issue by itself.

@bietkul Could you perhaps re-open this issue?

bietkul commented 4 years ago

@ShahAnuj2610 Can you please check it.

ShahAnuj2610 commented 4 years ago

I agree with @janus-reith, the includeNullValues prop does not solve this issue by itself.

@bietkul Could you perhaps re-open this issue?

As of now, this approach should work => https://github.com/appbaseio/reactivesearch/issues/1096#issuecomment-528411554