reactivesearch icon indicating copy to clipboard operation
reactivesearch copied to clipboard

DataSearch component fails to reset input or reset own filter when a CustomQuery is used

Open alexlle opened this issue 7 years ago • 4 comments

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]

alexlle avatar Jan 24 '19 18:01 alexlle

Please specify the version of reactivesearch you're using.

metagrover avatar Jan 24 '19 18:01 metagrover

@metagrover v2.16.0

alexlle avatar Jan 24 '19 19:01 alexlle

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;
}}

metagrover avatar Jan 24 '19 19:01 metagrover

OMG Thank you so much! =)

alexlle avatar Jan 24 '19 19:01 alexlle