From aaa4c98dd33e0bc14bee178008eaa2a4b9648a48 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Thu, 5 Jul 2018 16:39:41 -0700 Subject: [PATCH] Only prevent search on pageload, otherwise claer wont be called --- src/js/app.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/js/app.js b/src/js/app.js index 3d84b04eec6..20d939de907 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -4,21 +4,31 @@ import instantsearch from 'instantsearch.js'; // This is for any custom JS that may need to be added to individual apps. // Main JS is located in Rancher Website Theme const bootstrapDocsSearch = function() { + + var firstSearchRender = true; + const search = instantsearch({ appId: '30NEY6C9UY', apiKey: 'b7f43c16886fec97b87981e9e62ef1a5', indexName: window.location.host === 'rancher.com' ? 'prod_docs' : 'dev_docs', routing: true, - searchFunction: function(helper) { - if (helper.state.query === "") { + searchFunction: (helper) => { + + if (helper.state.query === "" && firstSearchRender) { + + firstSearchRender = false; + return; } + helper.search(); } }); search.addWidget( instantsearch.widgets.searchBox({ + autofocus: true, + loadingIndicator: true, container: '#search-box', placeholder: 'Search Docs...', magnifier: false,