Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ombibar input to search suggestion callback #1262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

soraxas
Copy link

@soraxas soraxas commented Jun 19, 2020

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.

https://api-portal.dictionary.com/spellSuggestions/${WORD}

to provide spell suggestion, and
2.

https://tuna.thesaurus.com/pageData/${WORD}

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.

Signed-off-by: Tin Lai <oscar@tinyiu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant