From 9a930e74da862944e4e32935e208fd7fec506e9c Mon Sep 17 00:00:00 2001 From: vvo Date: Thu, 25 Feb 2016 17:55:47 +0100 Subject: [PATCH] feat(instantsearch): allow overriding the helper.search function add a new option to the instantsearch: searchFunction. It allows user to override the default call to helper.search() by anything they want. With this, they will be able to implement: - do not search at first render - do not search when query < 3 chars - any conditional we cannot think of --- dev/app.js | 9 ++-- dev/index.html | 58 +++++++++++++------------ dev/style.css | 8 +--- src/lib/InstantSearch.js | 28 ++++++++++-- src/lib/__tests__/InstantSearch-test.js | 21 ++++++++- 5 files changed, 81 insertions(+), 43 deletions(-) diff --git a/dev/app.js b/dev/app.js index a45e50d527..04c834c0d6 100644 --- a/dev/app.js +++ b/dev/app.js @@ -302,10 +302,6 @@ search.addWidget( }) ); -search.once('render', function() { - document.querySelector('.search').className = 'row search search--visible'; -}); - search.addWidget( instantsearch.widgets.priceRanges({ container: '#price-ranges', @@ -338,5 +334,10 @@ search.addWidget( }) ); +search.once('render', function() { + [...document.querySelectorAll('.smooth-search--hidden')] + .forEach(element => element.classList.remove('smooth-search--hidden')); +}); + search.start(); diff --git a/dev/index.html b/dev/index.html index d48b10774c..78cb7079e2 100644 --- a/dev/index.html +++ b/dev/index.html @@ -19,8 +19,8 @@

Instant search demo using instantsearch.js

-