File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -886,11 +886,13 @@ the specific language governing permissions and limitations under the Apache Lic
886886 height = this . container . outerHeight ( false ) ,
887887 width = this . container . outerWidth ( false ) ,
888888 dropHeight = this . dropdown . outerHeight ( false ) ,
889+ viewPortRight = $ ( window ) . scrollLeft ( ) + document . documentElement . clientWidth ,
889890 viewportBottom = $ ( window ) . scrollTop ( ) + document . documentElement . clientHeight ,
890891 dropTop = offset . top + height ,
891892 dropLeft = offset . left ,
892893 enoughRoomBelow = dropTop + dropHeight <= viewportBottom ,
893894 enoughRoomAbove = ( offset . top - dropHeight ) >= this . body ( ) . scrollTop ( ) ,
895+ enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight ,
894896 aboveNow = this . dropdown . hasClass ( "select2-drop-above" ) ,
895897 bodyOffset ,
896898 above ,
@@ -917,6 +919,10 @@ the specific language governing permissions and limitations under the Apache Lic
917919 if ( ! enoughRoomBelow && enoughRoomAbove ) above = true ;
918920 }
919921
922+ if ( ! enoughRoomOnRight ) {
923+ dropLeft = offset . left + width - dropWidth ;
924+ }
925+
920926 if ( above ) {
921927 dropTop = offset . top - dropHeight ;
922928 this . container . addClass ( "select2-drop-above" ) ;
You can’t perform that action at this time.
0 commit comments