From dc538930a7cb64b04b2793f83b955b284ac55146 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 4 Nov 2015 17:11:40 -0800 Subject: [PATCH] fix(search): Allow typing in the middle of the search text --- internal_packages/search-bar/lib/search-bar.cjsx | 3 ++- .../search-bar/lib/search-suggestion-store.coffee | 13 +++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/internal_packages/search-bar/lib/search-bar.cjsx b/internal_packages/search-bar/lib/search-bar.cjsx index 5bc3d1f23..061f91406 100644 --- a/internal_packages/search-bar/lib/search-bar.cjsx +++ b/internal_packages/search-bar/lib/search-bar.cjsx @@ -105,10 +105,11 @@ class SearchBar extends React.Component str += val else str += val + str _stringToQuery: (str) => return [] unless str - return [all: str] + return [{all: str}] _onValueChange: (event) => Actions.searchQueryChanged(@_stringToQuery(event.target.value)) diff --git a/internal_packages/search-bar/lib/search-suggestion-store.coffee b/internal_packages/search-bar/lib/search-suggestion-store.coffee index 4942056b2..b660a6a9f 100644 --- a/internal_packages/search-bar/lib/search-suggestion-store.coffee +++ b/internal_packages/search-bar/lib/search-suggestion-store.coffee @@ -24,29 +24,26 @@ SearchSuggestionStore = Reflux.createStore onSearchQueryChanged: (query) -> @_query = query - @_rebuildResults() + @trigger() + _.defer => @_rebuildResults() onSearchQueryCommitted: (query) -> @_query = query @_committedQuery = query @_clearResults() - @trigger() onSearchBlurred: -> @_clearResults() - @trigger() _clearResults: -> @_threadResults = null @_contactResults = null @_suggestions = [] + @trigger() _rebuildResults: -> {key, val} = @queryKeyAndVal() - unless key and val - @_clearResults() - @trigger(@) - return + return @_clearResults() unless key and val ContactStore.searchContacts(val, limit:10).then (results) => @_contactResults = results @@ -98,7 +95,7 @@ SearchSuggestionStore = Reflux.createStore contact: contact value: [{"all": contact.email}] - @trigger(@) + @trigger() # Exposed Data