I have a Select2 dropdown that is dynamically populated during page load. The dropdown has a defined placeholder text, and the loaded option lists have items with a text and a numerical value property.
If I populate the dropdown with a flat options list (without optgroups), everything works as expected. When an option is selected, it is highlighted as selected in the dropdown list, and the option text is displayed instead of the placeholder for the dropdown.
If I populate the dropdown with options defined in optgroups, the dropdown will act weirdly. When an option is selected, it is highlighted as selected in the dropdown list, but the placeholder is still displayed for the dropdown.
What am I doing wrong?