From 36683ff1e3838bb817e892c4045212cdc7c331a3 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 4 Feb 2014 13:19:36 -0500 Subject: [PATCH] FIX: Searching for spaces wouldn't stop spinning --- .../javascripts/discourse/controllers/search_controller.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/search_controller.js b/app/assets/javascripts/discourse/controllers/search_controller.js index c6db93b9ed1..ccb8c4c8e59 100644 --- a/app/assets/javascripts/discourse/controllers/search_controller.js +++ b/app/assets/javascripts/discourse/controllers/search_controller.js @@ -11,8 +11,8 @@ Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, { // If we need to perform another search newSearchNeeded: function() { this.set('noResults', false); - var term = this.get('term'); - if (term && term.length >= Discourse.SiteSettings.min_search_term_length) { + var term = (this.get('term') || '').trim(); + if (term.length >= Discourse.SiteSettings.min_search_term_length) { this.set('loading', true); this.searchTerm(term, this.get('typeFilter')); } else { @@ -57,6 +57,8 @@ Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, { self.set('urls', urls); } + self.set('loading', false); + }).catch(function() { self.set('loading', false); }); }, 300),