This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 1288
1288
$select . disableChoiceExpression = attrs . uiDisableChoice ;
1289
1289
$select . onHighlightCallback = attrs . onHighlight ;
1290
1290
1291
- $select . refreshOnActive = attrs . refreshOnActive ;
1291
+ $select . refreshOnActive = scope . $eval ( attrs . refreshOnActive ) ;
1292
1292
1293
1293
if ( groupByExp ) {
1294
1294
var groups = element . querySelectorAll ( '.ui-select-choices-group' ) ;
1315
1315
scope . $watch ( '$select.search' , function ( newValue ) {
1316
1316
if ( newValue && ! $select . open && $select . multiple ) $select . activate ( false , true ) ;
1317
1317
$select . activeIndex = $select . tagging . isActivated ? - 1 : 0 ;
1318
- if ( angular . isUndefined ( $select . refreshOnActive ) || ( $select . refreshOnActive && $select . refreshIsActive ) ) {
1318
+ if ( ! $select . refreshOnActive || ( $select . refreshOnActive && $select . refreshIsActive ) ) {
1319
1319
$select . refresh ( attrs . refresh ) ;
1320
1320
}
1321
1321
} ) ;
1322
1322
1323
- scope . $watch ( '$select.refreshIsActive' , function ( value ) {
1324
- if ( angular . isUndefined ( value ) ) {
1323
+ scope . $watch ( '$select.refreshIsActive' , function ( newValue , oldValue ) {
1324
+ if ( angular . isUndefined ( oldValue ) && newValue ) {
1325
1325
$select . refresh ( attrs . refresh ) ;
1326
1326
}
1327
1327
} ) ;
Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ describe('ui-select tests', function() {
191
191
192
192
expect ( getMatchLabel ( el ) ) . toEqual ( 'Adam' ) ;
193
193
} ) ;
194
-
194
+
195
195
it ( 'should correctly render initial state with track by feature' , function ( ) {
196
196
var el = compileTemplate (
197
197
'<ui-select ng-model="selection.selected"> \
@@ -1791,4 +1791,33 @@ describe('ui-select tests', function() {
1791
1791
}
1792
1792
} ) ;
1793
1793
} ) ;
1794
+
1795
+ describe ( 'with refresh on active' , function ( ) {
1796
+ it ( 'should not refresh untill is activate' , function ( ) {
1797
+
1798
+ var el = compileTemplate (
1799
+ '<ui-select ng-model="selection.selected"> \
1800
+ <ui-select-match> \
1801
+ </ui-select-match> \
1802
+ <ui-select-choices repeat="person in people | filter: $select.search" \
1803
+ refresh="fetchFromServer($select.search)" refresh-on-active="true" refresh-delay="0"> \
1804
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1805
+ <div ng-if="person.name==\'Wladimir\'"> \
1806
+ <span class="only-once">I should appear only once</span>\
1807
+ </div> \
1808
+ </ui-select-choices> \
1809
+ </ui-select>'
1810
+ ) ;
1811
+
1812
+ scope . fetchFromServer = function ( ) { } ;
1813
+ spyOn ( scope , 'fetchFromServer' ) ;
1814
+ $timeout . flush ( ) ;
1815
+ expect ( scope . fetchFromServer . calls . any ( ) ) . toEqual ( false ) ;
1816
+
1817
+ el . scope ( ) . $select . activate ( ) ;
1818
+ $timeout . flush ( ) ;
1819
+ expect ( scope . fetchFromServer . calls . any ( ) ) . toEqual ( true ) ;
1820
+ } ) ;
1821
+
1822
+ } ) ;
1794
1823
} ) ;
You can’t perform that action at this time.
0 commit comments