mirror of
https://github.com/rancher/rancher-docs.git
synced 2026-09-26 21:18:04 +00:00
Merge pull request #404 from westlywright/master
Only prevent search on pageload, otherwise clear wont be called
This commit is contained in:
+12
-2
@@ -4,21 +4,31 @@ import instantsearch from 'instantsearch.js';
|
|||||||
// This is for any custom JS that may need to be added to individual apps.
|
// This is for any custom JS that may need to be added to individual apps.
|
||||||
// Main JS is located in Rancher Website Theme
|
// Main JS is located in Rancher Website Theme
|
||||||
const bootstrapDocsSearch = function() {
|
const bootstrapDocsSearch = function() {
|
||||||
|
|
||||||
|
var firstSearchRender = true;
|
||||||
|
|
||||||
const search = instantsearch({
|
const search = instantsearch({
|
||||||
appId: '30NEY6C9UY',
|
appId: '30NEY6C9UY',
|
||||||
apiKey: 'b7f43c16886fec97b87981e9e62ef1a5',
|
apiKey: 'b7f43c16886fec97b87981e9e62ef1a5',
|
||||||
indexName: window.location.host === 'rancher.com' ? 'prod_docs' : 'dev_docs',
|
indexName: window.location.host === 'rancher.com' ? 'prod_docs' : 'dev_docs',
|
||||||
routing: true,
|
routing: true,
|
||||||
searchFunction: function(helper) {
|
searchFunction: (helper) => {
|
||||||
if (helper.state.query === "") {
|
|
||||||
|
if (helper.state.query === "" && firstSearchRender) {
|
||||||
|
|
||||||
|
firstSearchRender = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.search();
|
helper.search();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
search.addWidget(
|
search.addWidget(
|
||||||
instantsearch.widgets.searchBox({
|
instantsearch.widgets.searchBox({
|
||||||
|
autofocus: true,
|
||||||
|
loadingIndicator: true,
|
||||||
container: '#search-box',
|
container: '#search-box',
|
||||||
placeholder: 'Search Docs...',
|
placeholder: 'Search Docs...',
|
||||||
magnifier: false,
|
magnifier: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user