Allow custom query on autosuggest based on input #2136
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
This proposed change aims to resolve issue #2135 where a custom query can be made based on the
input
elementbefore the search fetch happens.
The change shouldn't impact any current users and will allow any new implementations to use a javascript function called
window.epCustomQuery
to return a modified version of thewindow.epas
on the fly.Alternate Designs
There were considered two alternatives to this PR:
esSearch
function on the very top was considered because it would eventually benefit of thesearchText
length but it looked a bit offset as there was already a place where thequeryJSON
is defined.window.fetch()
to intercept the query but there would be no information about theinput
at that moment which would make it hard to achieve that goal.Benefits
It will enable users to search using different inputs with different queries, including post types and other parameters.
Possible Drawbacks
A possible drawback is that a malformed query customization could lead to further errors down stream.
Verification Process
Checklist:
Applicable Issues
closes #2135
Changelog Entry
Allow query customization for autosuggest before fetching the search based on the input field.