reactivesearch icon indicating copy to clipboard operation
reactivesearch copied to clipboard

reset custom component input after clearing from SelectedFilters

Open nestedifsdotcom opened this issue 8 years ago • 10 comments

doc enhancement Platform: web

Description:

i added a custom reactive component `import React, { Component } from "react"; class ChildInput extends Component { setValue = value => { this.props.setQuery({ query: this.props.query(value), value: value }); }; render() { return (

<input onChange={e => { if (e.target.value === "") { this.props.setQuery({ query: { match_all: {} }, value: "" }); } if (e.target.value >= 0) { this.setValue(e.target.value, valueSuffixe); } }} />
); } }

export default ChildInput;` i wrapped the component inside a ReactiveComponent and it works, it filters the results perfectly but i didn't find how to clear the input field after the clear on the SelectedFilters component is there an event for that ?

Minimal reproduction of the problem with instructions:

Reactivesearch version: 2.6.2"

Anything else: i suggest to add an event to the custom component like "onSelectedFiltersClear"

nestedifsdotcom avatar Jul 14 '18 12:07 nestedifsdotcom

Since I might have the same issue, I created a sandbox to visualize my problem. When using the ToggleButton I can check/uncheck them and of course reset the filter correctly. Now I do have my own Reactive Component which works correctly when clicking on the stars, BUT will not be reset if you reset the filter.

axeff avatar Aug 30 '18 14:08 axeff

Updated sandbox. Now catching that selectedValue is null so I set value to 0 and some other dirty workaround (see componentWillReceiveProps in ReactiveStarRatingWrapper) but it's working

axeff avatar Aug 30 '18 15:08 axeff

Hi @axeff I'm facing a similar issue. I didn't get what dirty workaround you found. Could you explain more pls?

I use a CustomQuery for the DataSearch default component and it does NOT reset when I toggle the "clear all" filter button or when I press its own filter toggle button.

alexlle avatar Jan 24 '19 17:01 alexlle

Closing this issue because we support onClear event on SelectedFilters.

Refer updated docs here.

metagrover avatar Jan 24 '19 19:01 metagrover

The docs only say: onClear function [optional] Gets triggered when the clear all button is clicked.

It's not very clear, and i don't see any examples of this onClear function

Can you point us to an example?

DustinKLo avatar Apr 02 '19 05:04 DustinKLo

You can use it as:

<SelectedFilters onClear={(comp, val) => console.log(comp, val)} />

metagrover avatar Apr 02 '19 12:04 metagrover

@metagrover does the onClear prop work on native? I noticed that the documentation for SelectedFilters for Native doesn't include everything that the Web version has

dres-cifuentes avatar Apr 03 '19 14:04 dres-cifuentes

@dres-cifuentes No, it isn't supported on native yet. It should be very similar to implement though. Open to accepting PR on this :)

metagrover avatar Apr 03 '19 14:04 metagrover

@metagrover FYI, the docs (here at least https://opensource.appbase.io/reactive-manual/base-components/selectedfilters.html) Make mention of an onChange, not an onClear

iseabock avatar May 15 '19 18:05 iseabock

@jyash97 Can you update the docs

bietkul avatar May 15 '19 18:05 bietkul