hernansartorio / jquery-nice-select

A lightweight jQuery plugin that replaces native select elements with customizable dropdowns.
http://jqueryniceselect.hernansartorio.com
962 stars 285 forks source link

Overflow issue for fields that have a large amount of options/choices #30

Open dave4jr opened 8 years ago

dave4jr commented 8 years ago

I was having an issue where if I had a field with large amount of choices (i.e. - State or Country Field), there was no scrollbar and the list overflowed outside of the div. I fixed this by setting:

.nice-select .list { max-height: 300px; overflow: scroll; }

Sinequanonh commented 7 years ago

+1

Surbma commented 7 years ago

Just, what I needed. I've add a little fix:

.nice-select .list { max-height: 300px; overflow-y: scroll; }

kenshinman commented 7 years ago

Errrm, this didn't work until I added .open to .nice-select

.nice-select.open .list { max-height: 300px; overflow-y: scroll; }

yaniv-mobilebrain commented 7 years ago

Problem is, elements hidden atthe bottom of the list won't show up, and you need to take care of it in the click handler, to get the selected element into focus.

I solved it like this:

$(".nice-select.main").on("click", function() { setTimeout(function() { $(this).find(".list li.selected")[0].scrollIntoView(); }.bind(this), 100); });

basheer-atx commented 6 years ago

Not working for me

harontaiko commented 9 months ago

Apparently, combining @Surbma and @yaniv-mobilebrain' s solutions, fixed the problem of content overflowing inside a div and maintains a height of 300px and also the contents inside ul.list become scrollable Screenshot from 2024-01-25 09-00-46