@@ -65,6 +65,11 @@ uis.controller('uiSelectCtrl',
65
65
return isNil ( ctrl . selected ) || ctrl . selected === '' || ( ctrl . multiple && ctrl . selected . length === 0 ) ;
66
66
} ;
67
67
68
+ ctrl . getPlaceholder = function ( ) {
69
+ if ( ctrl . selected && ctrl . selected . length ) return ;
70
+ return ctrl . placeholder ;
71
+ } ;
72
+
68
73
function _findIndex ( collection , predicate , thisArg ) {
69
74
if ( collection . findIndex ) {
70
75
return collection . findIndex ( predicate , thisArg ) ;
@@ -88,10 +93,14 @@ uis.controller('uiSelectCtrl',
88
93
if ( ctrl . resetSearchInput ) {
89
94
ctrl . search = EMPTY_SEARCH ;
90
95
//reset activeIndex
91
- if ( ctrl . selected && ctrl . items . length && ! ctrl . multiple ) {
92
- ctrl . activeIndex = _findIndex ( ctrl . items , function ( item ) {
93
- return angular . equals ( this , item ) ;
94
- } , ctrl . selected ) ;
96
+ if ( ! ctrl . multiple ) {
97
+ if ( ctrl . selected && ctrl . items . length ) {
98
+ ctrl . activeIndex = _findIndex ( ctrl . items , function ( item ) {
99
+ return angular . equals ( this , item ) ;
100
+ } , ctrl . selected ) ;
101
+ } else {
102
+ ctrl . activeIndex = 0 ;
103
+ }
95
104
}
96
105
}
97
106
}
@@ -149,7 +158,7 @@ uis.controller('uiSelectCtrl',
149
158
} else {
150
159
$timeout ( function ( ) {
151
160
ctrl . focusSearchInput ( initSearchValue ) ;
152
- if ( ! ctrl . tagging . isActivated && ctrl . items . length > 1 ) {
161
+ if ( ! ctrl . tagging . isActivated && ctrl . items . length > 1 && ctrl . open ) {
153
162
_ensureHighlightVisible ( ) ;
154
163
}
155
164
} ) ;
@@ -166,9 +175,12 @@ uis.controller('uiSelectCtrl',
166
175
ctrl . searchInput [ 0 ] . focus ( ) ;
167
176
} ;
168
177
169
- ctrl . findGroupByName = function ( name ) {
178
+ ctrl . findGroupByName = function ( name , noStrict ) {
170
179
return ctrl . groups && ctrl . groups . filter ( function ( group ) {
171
- return group . name === name ;
180
+ if ( noStrict )
181
+ return group . name == name ;
182
+ else
183
+ return group . name === name ;
172
184
} ) [ 0 ] ;
173
185
} ;
174
186
@@ -465,11 +477,11 @@ uis.controller('uiSelectCtrl',
465
477
ctrl . toggle = function ( e ) {
466
478
if ( ctrl . open ) {
467
479
ctrl . close ( ) ;
468
- e . preventDefault ( ) ;
469
- e . stopPropagation ( ) ;
470
480
} else {
471
481
ctrl . activate ( ) ;
472
482
}
483
+ e . preventDefault ( ) ;
484
+ e . stopPropagation ( ) ;
473
485
} ;
474
486
475
487
// Set default function for locked choices - avoids unnecessary
0 commit comments