Expose ombibar input to search suggestion callback #1262
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.
This simple PR exposes omnibar user's input to search suggestion callback.
There are scenario where you would want access to what user typed on Omnibar in the callback.
For example, I was creating a search suggestion for https://thesaurus.com. In the webpage, it uses multiple api calls where:
1.
to provide spell suggestion, and
2.
to provide the actual thesaurus result.
I want to make the ombibar preview the actual result (the No.2), but it losses the ability to provide spell suggestion (No.1) because the two api calls are distinct, meaning that if your spell is correct, api 1 would returns null (api 2 works as normal). If your spell is incorrect, api 1 would returns a list of suggested correctly-spelled words (api 2 would returns null as it's not within the dictionary).
I was trying to make api 2 URL as the suggestionURL, and fallback to api 1 if api 2 returns null (meaning your spell is incorrect and omnibar would provide suggestion of correctly spelled words).
However, there is currently no way to access what user had typed in the callback. This PR append the
Omnibar.input.value
to the callback, and should be backward-compatible to any previous script.