masylum/chosen — comment on commit 1ba161d5511b694a10e67ceff64a318245cebcaa
File:  line 0
By gdepourtales:

Thanks for the tip.

This works great but actually not when the search input is present. I modified the code (in jQuery flavour) like this to only depend on the results list height :

```javascript

Chosen.prototype.results_show = function() {
var dd_top, drop_bottom, hidden_drop, drop_results;
if (!this.is_multiple) {
this.selected_item.addClass("chzn-single-with-drop");
if (this.result_single_selected) {
this.result_do_highlight(this.result_single_selected);
}
}
dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
this.dropdown.css({
"top": dd_top + "px",
"left": 0
});
this.results_showing = true;

// See https://github.com/masylum/chosen/commit/1ba161d5511b694a10e67ceff64a318245cebcaa#diff-0
// for initial enhancement
drop_results = this.dropdown.find('.chzn-results');
drop_bottom = drop_results.offset().top + drop_results.height();
hidden_drop = drop_bottom - $(document).height();
if (hidden_drop) {
drop_results.css({height: drop_results.height() - hidden_drop});
}

this.search_field.focus();
this.search_field.val(this.search_field.val());
return this.winnow_results();
};

```