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

Commit 4d70390

Browse files
committed
refresh on active
1 parent 28466ab commit 4d70390

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/select.js

Lines changed: 15 additions & 2 deletions
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 ) {
@@ -1238,6 +1242,8 @@
12381242
$select.disableChoiceExpression = attrs.uiDisableChoice;
12391243
$select.onHighlightCallback = attrs.onHighlight;
12401244

1245+
$select.refreshOnActive = attrs.refreshOnActive;
1246+
12411247
if(groupByExp) {
12421248
var groups = element.querySelectorAll('.ui-select-choices-group');
12431249
if (groups.length !== 1) throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-group but got '{0}'.", groups.length);
@@ -1263,7 +1269,15 @@
12631269
scope.$watch('$select.search', function(newValue) {
12641270
if(newValue && !$select.open && $select.multiple) $select.activate(false, true);
12651271
$select.activeIndex = $select.tagging.isActivated ? -1 : 0;
1266-
$select.refresh(attrs.refresh);
1272+
if(angular.isUndefined($select.refreshOnActive) || ($select.refreshOnActive && $select.refreshIsActive)) {
1273+
$select.refresh(attrs.refresh);
1274+
}
1275+
});
1276+
1277+
scope.$watch('$select.refreshIsActive', function(value){
1278+
if(angular.isUndefined(value)){
1279+
$select.refresh(attrs.refresh);
1280+
}
12671281
});
12681282

12691283
attrs.$observe('refreshDelay', function() {
@@ -1329,4 +1343,3 @@
13291343
};
13301344
});
13311345
}());
1332-

0 commit comments

Comments
 (0)