Skip to content

Commit 8b566bf

Browse files
author
Igor Vaynberg
committed
fix hiding of search when minimumResultsForSearch are used. fixes select2#138
1 parent b7c952a commit 8b566bf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

select2.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,11 +1162,13 @@
11621162
// hide the search box if this is the first we got the results and there are a few of them
11631163

11641164
if (initial === true) {
1165+
// TODO below we use data.results.length, but what we really need is something recursive to calc the length
1166+
// TODO in case there are optgroups
11651167
showSearchInput = this.showSearchInput = data.results.length >= this.opts.minimumResultsForSearch;
1166-
this.container.find(".select2-search")[showSearchInput ? "removeClass" : "addClass"]("select2-search-hidden");
1168+
this.dropdown.find(".select2-search")[showSearchInput ? "removeClass" : "addClass"]("select2-search-hidden");
11671169

11681170
//add "select2-with-searchbox" to the container if search box is shown
1169-
this.container[showSearchInput ? "addClass" : "removeClass"]("select2-with-searchbox");
1171+
$(this.dropdown, this.container)[showSearchInput ? "addClass" : "removeClass"]("select2-with-searchbox");
11701172
}
11711173

11721174
},

0 commit comments

Comments
 (0)