panorama-ed / maximize-select2-height

Let your Select2 dropdowns take advantage of the space on the page.
52 stars 20 forks source link

Error when using multi-select boxes #12

Open creativitRy opened 6 years ago

creativitRy commented 6 years ago

Hello, thank you for this package!

When using a multi-select box/pillbox, the dropdown does not render properly when opening upwards. I looked through the code and realized that the line $("#select2-" + id + "-container") fails for a multi box because the down arrow does not exist.

I fixed this problem by changing the line to $("#" + id).parent().find(".select2").offset().top;, but this doesn't work when more than 1 select boxes exist in the parent.

JacobEvelyn commented 6 years ago

Thanks for the tip, @creativitRy! (And sorry for the slow response!)

Using the test.html file in this repository that we typically use for testing the behavior of this package, I see the problem you're describing but I'm not sure the solution you mentioned is working for me. Am I correct that the line you're changing is the widgetBoxOffset = ...?

creativitRy commented 6 years ago

Yes, that's the line I changed.

The solution I mentioned worked for my specific case where each select2 boxes were surrounded by a different div. I don't think this works for general cases.

JacobEvelyn commented 6 years ago

Gotcha, thanks! I'll try playing with this a bit more and see what I can come up with.

nbelley commented 5 years ago

Also have this problem on my side, not sure if it's a bug on your part... it would be easier to fix if select2 did the same thing with its container (adding id) when in multiple than in single...

I changed the code in select2 js to do that and it works fine.