Skip to content

Commit

Permalink
Merge pull request #2909 from 10up/feature/2908-filter-autosuggest-query
Browse files Browse the repository at this point in the history
Add epAutosuggestQueryFilter to allow filtering ES query based on input element
  • Loading branch information
felipeelia authored Jul 27, 2022
2 parents 4c65448 + 7aa12e3 commit 948b654
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions assets/js/autosuggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,13 @@ function init() {
query = JSON.stringify(query);
}

// Allow filtering the search query based on the input.
if (typeof window.epAutosuggestQueryFilter !== 'undefined') {
query = JSON.stringify(
window.epAutosuggestQueryFilter(JSON.parse(query), searchText, input),
);
}

// fetch the results
const response = await esSearch(query, searchText);

Expand Down

0 comments on commit 948b654

Please sign in to comment.