electronjs.org-old icon indicating copy to clipboard operation
electronjs.org-old copied to clipboard

prevent search filters from affecting search results

Open zeke opened this issue 7 years ago • 1 comments

Goal: User types is:app music, and we do a search for music without affecting the value of query in the state object. We want the search input element and the query param to remain intact, as the user typed it.

In InstantSearch.js, is it possible modify the query that is performed without modifying the query typed by the user (and the value of its query param)? In other words, user types is:app music. We do some custom stuff in the searchFunction, and want to actually strip is:app out of the query that’s performed. But by calling helper.setQuery we are affecting the user input and the query param.

I tried overriding the state after triggering a search, but this technique didn't work:

// restore the original query in the state
const newState = Object.assign({}, helper.getState(), {query: originalQuery})
helper.overrideStateWithoutTriggeringChangeEvent(newState)

zeke avatar Jun 21 '18 20:06 zeke

cc @haroenv

zeke avatar Jun 21 '18 21:06 zeke