Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(autocomplete): don't show the loading bar when hitting escape on …
Browse files Browse the repository at this point in the history
…an empty input

The loading bar was being shown if the user pressed escape on an empty autocomplete input.

Closes #7927.

Closes #7934
  • Loading branch information
crisbeto authored and ThomasBurleson committed Apr 8, 2016
1 parent f687d10 commit e821ae3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/components/autocomplete/autocomplete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('<md-autocomplete>', function() {

element.remove();
}));


it('should allow you to set an input id without floating label', inject(function() {
var scope = createScope(null, {inputId: 'custom-input-id'});
Expand Down Expand Up @@ -321,6 +321,26 @@ describe('<md-autocomplete>', function() {
element.remove();
}));

it('should not show the progressbar when hitting escape on an empty input', inject(function($mdConstant, $timeout) {
var scope = createScope();
var template = '\
<md-autocomplete\
md-search-text="searchText"\
md-items="item in match(searchText)">\
</md-autocomplete>';
var element = compile(template, scope);
var ctrl = element.controller('mdAutocomplete');

$timeout.flush();
scope.$apply(function() {
ctrl.keydown(keydownEvent($mdConstant.KEY_CODE.ESCAPE));
});

expect(element.find('md-progress-linear').length).toBe(0);

element.remove();
}));

it('should not close list on ENTER key if nothing is selected', inject(function($timeout, $mdConstant, $material) {
var scope = createScope();
var template = '\
Expand Down
2 changes: 1 addition & 1 deletion src/components/autocomplete/js/autocompleteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
case $mdConstant.KEY_CODE.ESCAPE:
event.stopPropagation();
event.preventDefault();
clearValue();
if ($scope.searchText) clearValue();

// Force the component to blur if they hit escape
doBlur(true);
Expand Down

0 comments on commit e821ae3

Please sign in to comment.