Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(autocomplete): selected item now properly updates
Browse files Browse the repository at this point in the history
Closes #1468
  • Loading branch information
Robert Messerle committed Feb 11, 2015
1 parent a9c16e0 commit 1307b94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/autocomplete/autocomplete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('<md-autocomplete>', function() {
ctrl.keydown({ keyCode: $mdConstant.KEY_CODE.ENTER, preventDefault: angular.noop });
scope.$apply();
expect(scope.searchText).toBe('foo');
expect(scope.selectedItem).toBe(scope.match(scope.searchText)[0]);
}));
});

Expand Down
3 changes: 2 additions & 1 deletion src/components/autocomplete/js/autocompleteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
}

function select (index) {
$scope.searchText = getDisplayValue(self.matches[index]) || $scope.searchText;
$scope.selectedItem = self.matches[index];
$scope.searchText = getDisplayValue($scope.selectedItem) || $scope.searchText;
self.hidden = true;
self.index = -1;
self.matches = [];
Expand Down

0 comments on commit 1307b94

Please sign in to comment.