No matter what I do, Select2 seems to calculate the wrong width and the option text gets cut off. I have tried this in both Chrome and Firefox and simplified things down to almost nothing with no success. Is this just a flawed plugin or is there something I'm missing that will make it calculate the correct size?
$('select').select2();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" media="screen" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
<select><option value="123">test option</option></select>
I have also tried setting width : "auto" in the Select2 options but this has the undesirable effect of making the width dynamic, i.e., it changes as you select options.
Select2 documentation container width
See below
You can use an alternative solution by taking the width of the select element with jQuery outerWidth and adding an additional number of pixels when setting the width parameter of the select2 plugin
You can set a width css inline select tag
You can use css class in select tag