Skip to content

Commit 0fa1138

Browse files
cbryeruser378230
authored andcommitted
fix(selectize): show placeholder when search disabled
Previously when searchEnabled was set to false, the placeholder would also be hidden on the selectize theme. This fix sets the search input to disabled rather then hidden when the searchEnabled attribute is set to false. Fixes angular-ui#949 and angular-ui#691
1 parent e610b4d commit 0fa1138

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

docs/examples/demo-disable-search.html

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ <h3>Bootstrap theme</h3>
2323
</small>
2424
</ui-select-choices>
2525
</ui-select>
26+
<hr />
27+
<p>Number Selected: {{ctrl.multipleDemo.selectedPeople.length}}</p>
28+
<ui-select multiple ng-model="ctrl.multipleDemo.selectedPeople" theme="bootstrap" search-enabled="ctrl.searchEnabled" ng-disabled="ctrl.disabled" style="min-width: 300px;" title="Choose a person">
29+
<ui-select-match placeholder="Select person...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match>
30+
<ui-select-choices repeat="person in ctrl.people | propsFilter: {name: $select.search, age: $select.search}">
31+
<div ng-bind-html="person.name | highlight: $select.search"></div>
32+
<small>
33+
email: {{person.email}}
34+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
35+
</small>
36+
</ui-select-choices>
37+
</ui-select>
2638

2739
<h3>Select2 theme</h3>
2840
<p>Selected: {{ctrl.person.selected}}</p>
@@ -36,7 +48,18 @@ <h3>Select2 theme</h3>
3648
</small>
3749
</ui-select-choices>
3850
</ui-select>
39-
51+
<hr />
52+
<p>Number Selected: {{ctrl.multipleDemo.selectedPeople.length}}</p>
53+
<ui-select multiple ng-model="ctrl.multipleDemo.selectedPeople" theme="select2" search-enabled="ctrl.searchEnabled" ng-disabled="ctrl.disabled" style="min-width: 300px;">
54+
<ui-select-match placeholder="Select person...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match>
55+
<ui-select-choices repeat="person in ctrl.people | propsFilter: {name: $select.search, age: $select.search}">
56+
<div ng-bind-html="person.name | highlight: $select.search"></div>
57+
<small>
58+
email: {{person.email}}
59+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
60+
</small>
61+
</ui-select-choices>
62+
</ui-select>
4063
<h3>Selectize theme</h3>
4164
<p>Selected: {{ctrl.country.selected}}</p>
4265
<ui-select ng-model="ctrl.country.selected" theme="selectize" search-enabled="ctrl.searchEnabled" ng-disabled="ctrl.disabled" style="width: 300px;">

src/common.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ body > .select2-container.open {
112112
margin-top: -2px; /* FIXME hardcoded value :-/ */
113113
}
114114

115-
.ui-select-container[theme="selectize"] .ui-select-search-hidden{
115+
.ui-select-container[theme="selectize"] input.ui-select-search-hidden{
116116
opacity: 0;
117117
height: 0;
118118
min-height: 0;
119119
padding: 0;
120120
margin: 0;
121121
border:0;
122+
width: 0;
122123
}
123124

124125
/* Bootstrap theme */

src/selectize/match.tpl.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
<div ng-hide="$select.searchEnabled && ($select.open || $select.isEmpty())" class="ui-select-match" ng-transclude></div>
1+
<div ng-show="(!$select.isEmpty() && !$select.open) || !$select.searchEnabled" class="ui-select-match">
2+
<span ng-hide="$select.searchEnabled || (!$select.isEmpty() && !$select.open)" class="ui-select-placeholder text-muted">{{$select.placeholder}}</span>
3+
<span ng-hide="$select.isEmpty() || $select.open" ng-transclude></span>
4+
</div>
5+
6+

0 commit comments

Comments
 (0)