Update DocSearch.js to latest version #27710
Merged
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.
The latest (2.6.2) docsearch.js version now displays results as standard
<a href>
links, allowing users toctrl
-click on them to trigger default browser behavior of opening in a new tab. This has been a been a long awaited feature and is now live.To maintain backward compatibility, this behavior has only been enabled to users that didn't define their own
handleSelected
method. Because the Bootstrap documentation uses its ownhandleSelected
, you won't be able toctrl
-clicks results as of today :/This PR updates your
docsearch()
code to take advantage of the new<a href>
template, by removing your customhandleSelected
and moving its behavior to thetransformData
call. Namely, what you wanted to avoid was jumping to the first<h1>
of the pages (source), which would prevent users from seeing the header. This PR checks if the suggestion targets the#content
anchor (meaning it goes to this first<h1>
) and if so, removes it.Behavior should be the same, but at least now you can enjoy the
ctrl
-click :)