Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 2c4204e

Browse files
committed
refresh on active
1 parent bacb9d0 commit 2c4204e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/select.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@
180180
ctrl.selected = undefined;
181181
ctrl.open = false;
182182
ctrl.focus = false;
183+
ctrl.refreshOnActive = undefined;
184+
ctrl.refreshIsActive = undefined;
183185
ctrl.focusser = undefined; //Reference to input element used to handle focus events
184186
ctrl.disabled = undefined; // Initialized inside uiSelect directive link function
185187
ctrl.searchEnabled = undefined; // Initialized inside uiSelect directive link function
@@ -224,6 +226,8 @@
224226

225227
ctrl.activeIndex = ctrl.activeIndex >= ctrl.items.length ? 0 : ctrl.activeIndex;
226228

229+
ctrl.refreshIsActive = true;
230+
227231
// ensure that the index is set to zero for tagging variants
228232
// that where first option is auto-selected
229233
if ( ctrl.activeIndex === -1 && ctrl.taggingLabel !== false ) {
@@ -1284,6 +1288,8 @@
12841288
$select.disableChoiceExpression = attrs.uiDisableChoice;
12851289
$select.onHighlightCallback = attrs.onHighlight;
12861290

1291+
$select.refreshOnActive = attrs.refreshOnActive;
1292+
12871293
if(groupByExp) {
12881294
var groups = element.querySelectorAll('.ui-select-choices-group');
12891295
if (groups.length !== 1) throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-group but got '{0}'.", groups.length);
@@ -1309,7 +1315,15 @@
13091315
scope.$watch('$select.search', function(newValue) {
13101316
if(newValue && !$select.open && $select.multiple) $select.activate(false, true);
13111317
$select.activeIndex = $select.tagging.isActivated ? -1 : 0;
1312-
$select.refresh(attrs.refresh);
1318+
if(angular.isUndefined($select.refreshOnActive) || ($select.refreshOnActive && $select.refreshIsActive)) {
1319+
$select.refresh(attrs.refresh);
1320+
}
1321+
});
1322+
1323+
scope.$watch('$select.refreshIsActive', function(value){
1324+
if(angular.isUndefined(value)){
1325+
$select.refresh(attrs.refresh);
1326+
}
13131327
});
13141328

13151329
attrs.$observe('refreshDelay', function() {

0 commit comments

Comments
 (0)