Skip to content

Commit 118b943

Browse files
author
markzegarelli
authored
Merge pull request #1970 from segmentio/FIX-search-keyboard-nav
Fixed search keyboard navigation
2 parents b8d6efd + 513eac9 commit 118b943

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

js/algolia/index.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const placeHolder = envApiKey != null ? 'Search the Segment documentation' : 'Se
1818
const searchClient = algoliasearch(appId, apiKey);
1919

2020
//insights
21-
insightsClient('init', { appId, apiKey });
21+
insightsClient('init', { appId, apiKey, useCookie: true });
2222
const algoliaInsightsPlugin = createAlgoliaInsightsPlugin({ insightsClient });
2323

2424
// define locations to separate invocation for mobile and desktop
@@ -39,9 +39,9 @@ function initAutocomplete(item){
3939
sourceId: 'articles',
4040
getItemUrl({ item }){
4141
if (item.anchor != null) {
42-
var itemUrl = item.url+"#" + item.anchor;
42+
var itemUrl = '/docs'+item.url+"#" + item.anchor;
4343
} else {
44-
var itemUrl = item.url;
44+
var itemUrl = '/docs'+item.url;
4545
}
4646
return itemUrl;
4747
},
@@ -87,9 +87,19 @@ function initAutocomplete(item){
8787
},
8888
navigator: {
8989
navigate({ itemUrl }) {
90-
window.location.assign('/docs'+itemUrl);
90+
window.location.assign(itemUrl);
9191
},
92-
}
92+
navigateNewTab({ itemUrl }) {
93+
const windowReference = window.open(itemUrl, '_blank', 'noopener');
94+
95+
if (windowReference) {
96+
windowReference.focus();
97+
}
98+
},
99+
navigateNewWindow({ itemUrl }) {
100+
window.open(itemUrl, '_blank', 'noopener');
101+
},
102+
},
93103
});
94104

95105
}

0 commit comments

Comments
 (0)