@@ -65,6 +65,11 @@ uis.controller('uiSelectCtrl',
6565 return isNil ( ctrl . selected ) || ctrl . selected === '' || ( ctrl . multiple && ctrl . selected . length === 0 ) ;
6666 } ;
6767
68+ ctrl . getPlaceholder = function ( ) {
69+ if ( ctrl . selected && ctrl . selected . length ) return ;
70+ return ctrl . placeholder ;
71+ } ;
72+
6873 function _findIndex ( collection , predicate , thisArg ) {
6974 if ( collection . findIndex ) {
7075 return collection . findIndex ( predicate , thisArg ) ;
@@ -88,10 +93,14 @@ uis.controller('uiSelectCtrl',
8893 if ( ctrl . resetSearchInput ) {
8994 ctrl . search = EMPTY_SEARCH ;
9095 //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+ }
95104 }
96105 }
97106 }
@@ -149,7 +158,7 @@ uis.controller('uiSelectCtrl',
149158 } else {
150159 $timeout ( function ( ) {
151160 ctrl . focusSearchInput ( initSearchValue ) ;
152- if ( ! ctrl . tagging . isActivated && ctrl . items . length > 1 ) {
161+ if ( ! ctrl . tagging . isActivated && ctrl . items . length > 1 && ctrl . open ) {
153162 _ensureHighlightVisible ( ) ;
154163 }
155164 } ) ;
@@ -166,9 +175,12 @@ uis.controller('uiSelectCtrl',
166175 ctrl . searchInput [ 0 ] . focus ( ) ;
167176 } ;
168177
169- ctrl . findGroupByName = function ( name ) {
178+ ctrl . findGroupByName = function ( name , noStrict ) {
170179 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 ;
172184 } ) [ 0 ] ;
173185 } ;
174186
@@ -465,11 +477,11 @@ uis.controller('uiSelectCtrl',
465477 ctrl . toggle = function ( e ) {
466478 if ( ctrl . open ) {
467479 ctrl . close ( ) ;
468- e . preventDefault ( ) ;
469- e . stopPropagation ( ) ;
470480 } else {
471481 ctrl . activate ( ) ;
472482 }
483+ e . preventDefault ( ) ;
484+ e . stopPropagation ( ) ;
473485 } ;
474486
475487 // Set default function for locked choices - avoids unnecessary
0 commit comments