harvesthq / chosen

Deprecated - Chosen is a library for making long, unwieldy select boxes more friendly.
http://harvesthq.github.io/chosen/
Other
21.85k stars 4.1k forks source link

Menu get truncated if the dropdown at the end of the page #3144

Open agmak opened 1 year ago

agmak commented 1 year ago

The menu get truncated if the dropdown at the end of the page, I fixed this issue by calling setMenuLocation function from the end of fucntion " AbstractChosen.prototype.winnow_results "

if (!(options != null ? options.skip_highlight : void 0)) { //calling the function here setMenuLocation(this.dropdown[0], this.search_choices[0]); return this.winnow_results_set_highlight(); }

this function will determine if you are at the end of the page and will switch the menu to show at the top of the search choices.

function setMenuLocation(node, chosen) { var docH = document.documentElement.offsetHeight; var y = node.getBoundingClientRect().y; var h = node.offsetHeight; var pH = chosen.offsetHeight; var pY = chosen.getBoundingClientRect().y; if ((pY + h + pH) > (docH - 50)) { node.style.top = (-h) + "px"; } else if (y != 0 && h != 0) { node.style.top = "100%" } }