Include this javascript function in your page directly after the "select2.js" file. Then, set the dropdownPosition option to below wherever you initialize Select2.
And now, with a little CSS and JS, and with no modification to Select2's source code, you will have a Select2 plugin that behaves itself much more predictably.
Web advice in your inbox
Each month, learn to improve your website, enhance your users' experience, and become people-first in your online strategy.