FIX: never perform searches that bypass validation
we must perform another isValidSearchTerm check when we are about to perform search cause the call is debounced
This commit is contained in:
parent
d25dc126f7
commit
a5b0445e02
|
@ -34,6 +34,12 @@ const SearchHelper = {
|
||||||
const searchContext = contextEnabled ? widget.searchContext() : null;
|
const searchContext = contextEnabled ? widget.searchContext() : null;
|
||||||
const fullSearchUrl = widget.fullSearchUrl();
|
const fullSearchUrl = widget.fullSearchUrl();
|
||||||
|
|
||||||
|
if (!isValidSearchTerm(term)) {
|
||||||
|
state.noResults = true;
|
||||||
|
state.results = [];
|
||||||
|
state.loading = false;
|
||||||
|
widget.scheduleRerender();
|
||||||
|
} else {
|
||||||
this._activeSearch = searchForTerm(term, { typeFilter, searchContext, fullSearchUrl });
|
this._activeSearch = searchForTerm(term, { typeFilter, searchContext, fullSearchUrl });
|
||||||
this._activeSearch.then(content => {
|
this._activeSearch.then(content => {
|
||||||
state.noResults = content.resultTypes.length === 0;
|
state.noResults = content.resultTypes.length === 0;
|
||||||
|
@ -44,6 +50,7 @@ const SearchHelper = {
|
||||||
this._activeSearch = null;
|
this._activeSearch = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default createWidget('search-menu', {
|
export default createWidget('search-menu', {
|
||||||
|
|
Loading…
Reference in New Issue