diff --git a/horizon/static/framework/widgets/magic-search/magic-search.controller.js b/horizon/static/framework/widgets/magic-search/magic-search.controller.js index 47a29ae589..12901e5ce8 100644 --- a/horizon/static/framework/widgets/magic-search/magic-search.controller.js +++ b/horizon/static/framework/widgets/magic-search/magic-search.controller.js @@ -334,6 +334,10 @@ delete ctrl.textSearch; } else { $scope.$emit(magicSearchEvents.SEARCH_UPDATED, query); + if (angular.isDefined(ctrl.textSearch)) { + // emit text search if text facet remains + emitTextSearch(ctrl.textSearch || ''); + } if (ctrl.currentSearch.length > 0) { // prune facets as needed from menus var newFacet = ctrl.currentSearch[ctrl.currentSearch.length - 1].name; diff --git a/horizon/static/framework/widgets/magic-search/magic-search.controller.spec.js b/horizon/static/framework/widgets/magic-search/magic-search.controller.spec.js index 2652a53b58..8f307b3660 100644 --- a/horizon/static/framework/widgets/magic-search/magic-search.controller.spec.js +++ b/horizon/static/framework/widgets/magic-search/magic-search.controller.spec.js @@ -509,6 +509,14 @@ expect(scope.strings.prompt).toEqual(''); }); + it("emits textSearch if text facet remains", function() { + spyOn(scope, '$emit'); + ctrl.currentSearch = [{}]; + ctrl.textSearch = 'cat'; + ctrl.removeFacet(0); + expect(scope.$emit).toHaveBeenCalledWith(magicSearchEvents.TEXT_SEARCH, 'cat', undefined); + }); + it("resets state if facet selected", function() { ctrl.currentSearch = [{}]; ctrl.facetSelected = {};