File tree Expand file tree Collapse file tree 3 files changed +37
-12
lines changed Expand file tree Collapse file tree 3 files changed +37
-12
lines changed Original file line number Diff line number Diff line change 42
42
< fieldset >
43
43
< legend > ui-select inside a Bootstrap form</ legend >
44
44
45
- < div class ="form-group ">
46
- < label class ="col-sm-3 control-label "> Default</ label >
47
- < div class ="col-sm-6 ">
45
+ < div class ="form-group ">
46
+ < label class ="col-sm-3 control-label "> Default</ label >
47
+ < div class ="col-sm-6 ">
48
+
49
+ < ui-select ng-model ="person.selected " theme ="bootstrap ">
50
+ < ui-select-match placeholder ="Select or search a person in the list... "> {{$select.selected.name}}</ ui-select-match >
51
+ < ui-select-choices repeat ="item in people | filter: $select.search ">
52
+ < div ng-bind-html ="item.name | highlight: $select.search "> </ div >
53
+ < small ng-bind-html ="item.email | highlight: $select.search "> </ small >
54
+ </ ui-select-choices >
55
+ </ ui-select >
56
+
57
+ </ div >
58
+ </ div >
48
59
49
- < ui-select ng-model ="person.selected " theme ="bootstrap ">
50
- < ui-select-match placeholder ="Select or search a person in the list... "> {{$select.selected.name}}</ ui-select-match >
51
- < ui-select-choices repeat ="item in people | filter: $select.search ">
52
- < div ng-bind-html ="item.name | highlight: $select.search "> </ div >
53
- < small ng-bind-html ="item.email | highlight: $select.search "> </ small >
54
- </ ui-select-choices >
55
- </ ui-select >
60
+ < div class ="form-group ">
61
+ < label class ="col-sm-3 control-label "> Search Disabled</ label >
62
+ < div class ="col-sm-6 ">
56
63
64
+ < ui-select ng-model ="person.selected " theme ="bootstrap " search-enabled ="false ">
65
+ < ui-select-match placeholder ="Select or search a person in the list... "> {{$select.selected.name}}</ ui-select-match >
66
+ < ui-select-choices repeat ="item in people | filter: $select.search ">
67
+ < div ng-bind-html ="item.name | highlight: $select.search "> </ div >
68
+ < small ng-bind-html ="item.email | highlight: $select.search "> </ small >
69
+ </ ui-select-choices >
70
+ </ ui-select >
71
+
72
+ </ div >
57
73
</ div >
58
- </ div >
59
74
60
75
< div class ="form-group ">
61
76
< label class ="col-sm-3 control-label "> Grouped</ label >
Original file line number Diff line number Diff line change 8
8
class ="form-control ui-select-search "
9
9
placeholder ="{{$select.placeholder}} "
10
10
ng-model ="$select.search "
11
- ng-show ="$select.searchEnabled && $select. open ">
11
+ ng-show ="$select.open ">
12
12
< div class ="ui-select-choices "> </ div >
13
13
</ div >
Original file line number Diff line number Diff line change @@ -79,6 +79,9 @@ uis.controller('uiSelectCtrl',
79
79
$scope . $broadcast ( 'uis:activate' ) ;
80
80
81
81
ctrl . open = true ;
82
+ if ( ! ctrl . searchEnabled ) {
83
+ angular . element ( ctrl . searchInput [ 0 ] ) . addClass ( 'ui-select-offscreen' ) ;
84
+ }
82
85
83
86
ctrl . activeIndex = ctrl . activeIndex >= ctrl . items . length ? 0 : ctrl . activeIndex ;
84
87
@@ -94,6 +97,10 @@ uis.controller('uiSelectCtrl',
94
97
ctrl . searchInput [ 0 ] . focus ( ) ;
95
98
} ) ;
96
99
}
100
+ else if ( ctrl . open && ! ctrl . searchEnabled ) {
101
+ // Close the selection if we don't have search enabled, and we click on the select again
102
+ ctrl . close ( ) ;
103
+ }
97
104
} ;
98
105
99
106
ctrl . findGroupByName = function ( name ) {
@@ -312,6 +319,9 @@ uis.controller('uiSelectCtrl',
312
319
if ( ctrl . ngModel && ctrl . ngModel . $setTouched ) ctrl . ngModel . $setTouched ( ) ;
313
320
_resetSearchInput ( ) ;
314
321
ctrl . open = false ;
322
+ if ( ! ctrl . searchEnabled ) {
323
+ angular . element ( ctrl . searchInput [ 0 ] ) . removeClass ( 'ui-select-offscreen' ) ;
324
+ }
315
325
316
326
$scope . $broadcast ( 'uis:close' , skipFocusser ) ;
317
327
You can’t perform that action at this time.
0 commit comments