From bb01d5c90c7266117a13c61617bcc2de29e5088f Mon Sep 17 00:00:00 2001 From: Joshua Pinter Date: Tue, 4 Feb 2020 13:39:14 -0700 Subject: [PATCH] Return all results when no query is present. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows you to set `minLength: 0` and get default values back when a query is run. This is a PR of @NipunaMarcus's work in this Issue: https://github.com/corejavascript/typeahead.js/issues/44 Will likely need to update the dist version as well. But hoping to get some 👀 on this and get it merged in so we can use the main branch in our app. --- src/bloodhound/search_index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/bloodhound/search_index.js b/src/bloodhound/search_index.js index 0577c4fbf2..712de9ff02 100644 --- a/src/bloodhound/search_index.js +++ b/src/bloodhound/search_index.js @@ -103,6 +103,13 @@ var SearchIndex = window.SearchIndex = (function() { } } }); + + if (!query) { + matches = []; + for (var obj in that.datums) { + matches.push(obj); + } + } return matches ? _.map(unique(matches), function(id) { return that.datums[id]; }) : [];