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

feat(SearchBar): call onSelect when it's provided #770

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,13 @@ class SearchBar extends Component {
this.setState({ query: null, searching: false })
}

onSuggestionSelected = (event, { suggestion }) => {
onSuggestionSelected = async (event, { suggestion }) => {
const { onSelect } = suggestion
// `onSelect` is a string that describes what should happen when the suggestion is selected. Currently, the only format we're supporting is `open:http://example.com` to change the url of the current page.

if (/^open:/.test(onSelect)) {
if (typeof onSelect === 'function') {
await onSelect()
trollepierre marked this conversation as resolved.
Show resolved Hide resolved
} else if (/^open:/.test(onSelect)) {
const url = onSelect.substr(5)
window.location.href = url
} else {
Expand Down