diff --git a/site/docs/4.1/assets/js/src/search.js b/site/docs/4.1/assets/js/src/search.js index 546cca5c7e7d..459d412df9ac 100644 --- a/site/docs/4.1/assets/js/src/search.js +++ b/site/docs/4.1/assets/js/src/search.js @@ -32,12 +32,6 @@ algoliaOptions: { facetFilters: ['version:' + siteDocsVersion] }, - handleSelected: function (input, event, suggestion) { - var url = suggestion.url - url = suggestion.isLvl1 ? url.split('#')[0] : url - // If it's a title we remove the anchor so it does not jump. - window.location.href = url - }, transformData: function (hits) { return hits.map(function (hit) { var siteurl = getOrigin() @@ -47,6 +41,12 @@ // otherwise remove our url from it. hit.url = siteurl.match(urlRE) ? hit.url : hit.url.replace(urlRE, '') + // Prevent jumping to first header + if (hit.anchor === 'content') { + hit.url = hit.url.replace(/#content$/, '') + hit.anchor = null + } + return hit }) },