You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Force showing dropdown-container always above or below #3121
As far as I know, there's no option which cover this.
Since it can't be just achieved via css customization, the only way is to intercept the opening of the select and the reposition the dropdown-container manually, but It's definitely not the best solution.
Any chance to see it in the upcoming v4.x?
There is a simpler way to implement a "forceabove" param:
In select2.js search for "positionDropdown: function()";
at the var settings change aboveNow = $dropdown.hasClass("select2-drop-above")
to aboveNow = this.opts.forceabove || $dropdown.hasClass("select2-drop-above")
Now you can setup select2 with option forceabove = true
Reacted by Joseph Hillhouse, Dmitry Khudorozhkov, shelart, Roman Markelov, coderX93, RadekHavelka, Prosperous, Aurovrata V. and Yoosaf
I was considering switching from Chosen to Select2, but I was surprised to see that this was something you couldn't control, and worse, it would be inconsistent: depending on the contents of the dropdown, it alternates between above and below.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
It looks like making the bottom value auto forcefully in CSS can also do the trick. I used the following code and it is kind of working for me fine. .my_select_picker_trigger.dropup .dropdown-menu { bottom: auto !important; }
There is a simpler way to implement a "forceabove" param:
1. In select2.js search for "positionDropdown: function()";
2. at the var settings change
`aboveNow = $dropdown.hasClass("select2-drop-above")`
to
`aboveNow = this.opts.forceabove || $dropdown.hasClass("select2-drop-above")`
3. Now you can setup select2 with option
`forceabove = true`
Activity
mh-nichts commentedon May 13, 2015
I would also be interested by this feature !
leonardomdr commentedon Aug 21, 2015
I did this in Select2 3.5.2 to force the container to start above instead of below the search box.
In select2.js you search for "positionDropdown: function() {" and change to "positionDropdown: function(forceAbove) {"
In the same function, after the var settings, paste this code:
After that, to force your select2 to show above, use this
apaulo commentedon Dec 31, 2015
There is a simpler way to implement a "forceabove" param:
In select2.js search for "positionDropdown: function()";
at the var settings change
aboveNow = $dropdown.hasClass("select2-drop-above")to
aboveNow = this.opts.forceabove || $dropdown.hasClass("select2-drop-above")Now you can setup select2 with option
forceabove = trueganholete commentedon Jan 8, 2016
Same question
tirdadc commentedon Jan 27, 2016
I was considering switching from Chosen to Select2, but I was surprised to see that this was something you couldn't control, and worse, it would be inconsistent: depending on the contents of the dropdown, it alternates between above and below.
fix : issues select2#3121 & select2#3354 - adding options for dropdow…
fix : select2#3121 - adding options for dropdown positionning
fix : select2#3121 - adding options for dropdown positionning
stale commentedon Mar 13, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon May 18, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
hassanrazmy commentedon Jan 18, 2021
It looks like making the bottom value auto forcefully in CSS can also do the trick. I used the following code and it is kind of working for me fine.
.my_select_picker_trigger.dropup .dropdown-menu { bottom: auto !important; }aurovrata commentedon Sep 13, 2021
following @apaulo solution...
in the latest version, you want to use
this.options.get('forceabove')mehulvardiya commentedon Sep 7, 2024