Is it possible to force to re-render the dropdown, so the position is recalculated?
There is no built-in option to do this. Your best bet is to destroy and then re-initialize the Select2 widget; however, if you’re using an AJAX data source then any currently loaded data will be wiped out. So if that’s the case and it’s important for you to preserve the current state of the widget before you destroy it, you’d need to do that separately. (In that case the underlying HTML
<select> should contain any options that had been previously selected (including the currently selected one[s]), but it will not contain any other entries currently populating the dropdown. Since the underlying
<select> was manipulated by the Select2, I’m not sure whether destroying the widget would also reset [clear out] the
<select>. You could experiment and see what happens. At worst you’d need to save the state of the
<select> [i.e., it’s current list of `<option>`s and their `selected` states, destroy the current widget, re-initialize the select2, programmatically insert the previous `<option>`s, and then programmatically execute the same search query that was active [if any] at the time you destroyed the original widget.)