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

Commit 776a75e

Browse files
devversionThomasBurleson
authored andcommitted
fix(autocomplete): remove unnecessary execution
Currently when the `selectedItem` changes, we check for the `searchText` being changed as well. This requires querying the `getDisplayValue` function with the current `searchText`. When the `searchText` is empty, we could remove that unnecessary execution and just skip the comparison (Reduces queries) Also this improves the compatibility with the `virtual repeater`, since the repeater changes the scope bindings during runtime. e.g `searchText` will be set to `undefined` and a ignorable error will be thrown. Closes #9221
1 parent dfc9ae7 commit 776a75e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/components/autocomplete/js/autocompleteController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
330330
$scope.searchText = val;
331331
handleSelectedItemChange(selectedItem, previousSelectedItem);
332332
});
333-
} else if (previousSelectedItem) {
333+
} else if (previousSelectedItem && $scope.searchText) {
334334
getDisplayValue(previousSelectedItem).then(function(displayValue) {
335335
// Clear the searchText, when the selectedItem is set to null.
336336
// Do not clear the searchText, when the searchText isn't matching with the previous

0 commit comments

Comments
 (0)