docusaurus-lunr-search
docusaurus-lunr-search copied to clipboard
Search text not removed - when click the result which already an active url
Hi, The search text in the search bar is not removed once we click the search result.
Thanks for reporting @Nilanth, I will take a look :+1:
This issue happens only when you select a result which is already an active URL..
No, it occurs on all pages! You can check in this demo itself https://lelouch77.github.io/docusaurus-lunr-search-demo/
When moving from landing page to documentation the search is cleared. However @Nilanth is right that once in the documentation, the search is never cleared.
Thats the old documentation link.. try this https://lelouch77.github.io/docusaurus-lunr-search-multilang @Nilanth @mattcorner
Its a bit inconsistent. Sometimes it does remove clear the search, but a lot of the time it doesn't. Here it is not clearing on the new demo @lelouch77
This only occurs for doc to doc navigation
Hi, The search text in the search bar is not removed once we click the search result.
On /src/theme/SearchBar/index.js
, I added _input.setVal('')
and _event.target.blur()
on the handleSelected
function (line 25):
const initAlgolia = (searchDocs, searchIndex, DocSearch) => {
new DocSearch({
searchDocs,
searchIndex,
inputSelector: "#search_input_react",
handleSelected: (_input, _event, suggestion) => {
const url = baseUrl + suggestion.url;
const a = document.createElement("a");
a.href = url;
_input.setVal(''); // clear value
_event.target.blur(); // remove focus
history.push(url);
}
});
};
So the input is cleared and its focus is removed when a result is clicked. Hope it helps!
fixed in new version 3.2.0