Skip to content

Commit aa23bf7

Browse files
committed
Merge branch 'fix_issue_453' into refactor_v1
* fix_issue_453: Fix test to check against ui-select-offscreen class, not ng-hide Update to move search box off screen Don't hide select when SearchEnable is false angular-ui#453 Conflicts: examples/bootstrap.html
2 parents 1a17265 + 1d9a673 commit aa23bf7

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/bootstrap/select.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
class="form-control ui-select-search"
99
placeholder="{{$select.placeholder}}"
1010
ng-model="$select.search"
11-
ng-show="$select.searchEnabled && $select.open">
11+
ng-show="$select.open">
1212
<div class="ui-select-choices"></div>
1313
</div>

src/uiSelectController.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ uis.controller('uiSelectCtrl',
7979
$scope.$broadcast('uis:activate');
8080

8181
ctrl.open = true;
82+
if(!ctrl.searchEnabled) {
83+
angular.element(ctrl.searchInput[0]).addClass('ui-select-offscreen');
84+
}
8285

8386
ctrl.activeIndex = ctrl.activeIndex >= ctrl.items.length ? 0 : ctrl.activeIndex;
8487

@@ -94,6 +97,10 @@ uis.controller('uiSelectCtrl',
9497
ctrl.searchInput[0].focus();
9598
});
9699
}
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+
}
97104
};
98105

99106
ctrl.findGroupByName = function(name) {
@@ -331,6 +338,9 @@ uis.controller('uiSelectCtrl',
331338
if (ctrl.ngModel && ctrl.ngModel.$setTouched) ctrl.ngModel.$setTouched();
332339
_resetSearchInput();
333340
ctrl.open = false;
341+
if(!ctrl.searchEnabled) {
342+
angular.element(ctrl.searchInput[0]).removeClass('ui-select-offscreen');
343+
}
334344

335345
$scope.$broadcast('uis:close', skipFocusser);
336346

test/select.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,13 +1497,13 @@ describe('ui-select tests', function() {
14971497
it('should show search input when true', function() {
14981498
setupSelectComponent('true', 'bootstrap');
14991499
clickMatch(el);
1500-
expect($(el).find('.ui-select-search')).not.toHaveClass('ng-hide');
1500+
expect($(el).find('.ui-select-search')).not.toHaveClass('ui-select-offscreen');
15011501
});
15021502

15031503
it('should hide search input when false', function() {
15041504
setupSelectComponent('false', 'bootstrap');
15051505
clickMatch(el);
1506-
expect($(el).find('.ui-select-search')).toHaveClass('ng-hide');
1506+
expect($(el).find('.ui-select-search')).toHaveClass('ui-select-offscreen');
15071507
});
15081508

15091509
});

0 commit comments

Comments
 (0)