DataSearch component fails to reset input or reset own filter when a CustomQuery is used
Issue Type: bug
Platform: ReactiveSearch for Web
Description: When I use a customQuery inside DataSearch component, I got the expected results but If I clear its filter or use "Clear All" toggle button, the results
Code <DataSearch
className="datasearch"
componentId="datasearch"
dataField={["title"]}
queryFormat="or"
highlight={true}
placeholder="Buscá..."
autosuggest={false}
URLParams={true}
innerClass={{
input: 'searchbox',
list: 'suggestionlist',
}}
iconPosition="left"
filterLabel="Palabras"
react={{"and": filtros }}
customQuery={ (value,props) => {
console.log(value,props)
return {
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "title:" +value+ " OR text:"+value,
"analyze_wildcard": true
}
}
]
}
}
}
}}
/>
Minimal reproduction of the problem with instructions: The issue is similar to this one: https://github.com/appbaseio/reactivesearch/issues/445
If I clear the input box all completely , I don't get all the results without filters as expected. I get the results as if I searched only the first char of what I did just searched.
If I remove the customQuery, all works fine.
Browser: [Chrome & Firefox]
Please specify the version of reactivesearch you're using.
@metagrover v2.16.0
Okay, it seems the issue is with your customQuery definition. Please check the query that you're firing from customQuery when you have no value (i.e. null).
Ideally, it should look like this:
customQuery={(value) => {
if (value) {
// if valid value, return your query
}
// otherwise return null query
return null;
}}
OMG Thank you so much! =)