Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

solution for issue #1059 when searchEnabled is false. #1114

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/match.tpl.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="ui-select-match" ng-hide="$select.open" ng-disabled="$select.disabled" ng-class="{'btn-default-focus':$select.focus}">
<div class="ui-select-match" ng-hide="$select.searchEnabled && $select.open" ng-disabled="$select.disabled" ng-class="{'btn-default-focus':$select.focus}">
<span tabindex="-1"
class="btn btn-default form-control ui-select-toggle"
aria-label="{{ $select.baseTitle }} activate"
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/select.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
aria-owns="ui-select-choices-{{ $select.generatedId }}"
aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}"
class="form-control ui-select-search"
ng-class="{'ui-select-search-hidden':!$select.searchEnabled}"
placeholder="{{$select.placeholder}}"
ng-model="$select.search"
ng-show="$select.searchEnabled && $select.open">
ng-show="$select.open">
<div class="ui-select-choices"></div>
</div>
</div>
29 changes: 28 additions & 1 deletion src/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ body > .select2-container.open {
border-bottom-color: #5897fb;
}

.ui-select-container[theme="select2"] .ui-select-dropdown .ui-select-search-hidden,
.ui-select-container[theme="select2"] .ui-select-dropdown .ui-select-search-hidden input{
opacity: 0;
height: 0;
min-height: 0;
padding: 0;
margin: 0;
border:0;
}

/* Selectize theme */

/* Helper class to show styles when focus */
Expand All @@ -90,10 +100,18 @@ body > .select2-container.open {
/* Handle up direction Selectize */
.ui-select-container[theme="selectize"].direction-up .ui-select-dropdown {
box-shadow: 0 -4px 8px rgba(0, 0, 0, 0.25);

margin-top: -2px; /* FIXME hardcoded value :-/ */
}

.ui-select-container[theme="selectize"] .ui-select-search-hidden{
opacity: 0;
height: 0;
min-height: 0;
padding: 0;
margin: 0;
border:0;
}

/* Bootstrap theme */

/* Helper class to show styles when focus */
Expand Down Expand Up @@ -136,6 +154,15 @@ body > .select2-container.open {
border-bottom-right-radius: 0 !important;
}

.ui-select-bootstrap .ui-select-search-hidden{
opacity: 0;
height: 0;
min-height: 0;
padding: 0;
margin: 0;
border:0;
}

.ui-select-bootstrap > .ui-select-match > .btn{
/* Instead of center because of .btn */
text-align: left !important;
Expand Down
2 changes: 1 addition & 1 deletion src/select2/select.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="ui-select-match"></div>
<div class="ui-select-dropdown select2-drop select2-with-searchbox select2-drop-active"
ng-class="{'select2-display-none': !$select.open}">
<div class="select2-search" ng-show="$select.searchEnabled">
<div class="search-container" ng-class="{'ui-select-search-hidden':!$select.searchEnabled, 'select2-search':$select.searchEnabled}">
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
role="combobox"
aria-expanded="true"
Expand Down
3 changes: 2 additions & 1 deletion src/selectize/select.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
<div class="ui-select-match"></div>
<input type="text" autocomplete="off" tabindex="-1"
class="ui-select-search ui-select-toggle"
ng-class="{'ui-select-search-hidden':!$select.searchEnabled}"
ng-click="$select.toggle($event)"
placeholder="{{$select.placeholder}}"
ng-model="$select.search"
ng-hide="!$select.searchEnabled || ($select.selected && !$select.open)"
ng-hide="$select.selected && !$select.open"
ng-disabled="$select.disabled"
aria-label="{{ $select.baseTitle }}">
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ uis.controller('uiSelectCtrl',
ctrl.searchInput[0].focus();
});
}
else if (ctrl.open && !ctrl.searchEnabled) {
// Close the selection if we don't have search enabled, and we click on the select again
ctrl.close();
}
};

ctrl.findGroupByName = function(name) {
Expand Down
12 changes: 6 additions & 6 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1278,12 +1278,12 @@ describe('ui-select tests', function() {

it('should show search input when true', function() {
setupSelectComponent(true, 'selectize');
expect($(el).find('.ui-select-search')).not.toHaveClass('ng-hide');
expect($(el).find('.ui-select-search')).not.toHaveClass('ui-select-search-hidden');
});

it('should hide search input when false', function() {
setupSelectComponent(false, 'selectize');
expect($(el).find('.ui-select-search')).toHaveClass('ng-hide');
expect($(el).find('.ui-select-search')).toHaveClass('ui-select-search-hidden');
});

});
Expand All @@ -1292,12 +1292,12 @@ describe('ui-select tests', function() {

it('should show search input when true', function() {
setupSelectComponent('true', 'select2');
expect($(el).find('.select2-search')).not.toHaveClass('ng-hide');
expect($(el).find('.search-container')).not.toHaveClass('ui-select-search-hidden');
});

it('should hide search input when false', function() {
setupSelectComponent('false', 'select2');
expect($(el).find('.select2-search')).toHaveClass('ng-hide');
expect($(el).find('.search-container')).toHaveClass('ui-select-search-hidden');
});

});
Expand All @@ -1307,13 +1307,13 @@ describe('ui-select tests', function() {
it('should show search input when true', function() {
setupSelectComponent('true', 'bootstrap');
clickMatch(el);
expect($(el).find('.ui-select-search')).not.toHaveClass('ng-hide');
expect($(el).find('.ui-select-search')).not.toHaveClass('ui-select-search-hidden');
});

it('should hide search input when false', function() {
setupSelectComponent('false', 'bootstrap');
clickMatch(el);
expect($(el).find('.ui-select-search')).toHaveClass('ng-hide');
expect($(el).find('.ui-select-search')).toHaveClass('ui-select-search-hidden');
});

});
Expand Down