I have a select2 dropdown in a responsive div. This div also has a sidebar element/column that contains the user's selections from the dropdown. They can select an option and it is added to the sidebar.
Everything works fine, but I have one option in the dropdown that is very long. If the user select this, the width of the parent div is expanded and pushes the sidebar down below the div.
I think this is happening because the option is exceeding some predetermined width by select2. Setting dropdownAutoWidth
to false
doesn't fix the issue, so I thought of adding a dropdownCssClass
with min-width
and max-width
set.
//in script.ts
$("#calltype").select2({ dropdownCssClass: 'smalldrop', width: 'auto' });
. . .
//calltype.scss
.smalldrop {
min-width: 113px !important;
max-width: 236px !important;
}
This will fix the issue, but now the dropdown isn't changing it's width to match the new width of the page if the user changes the screen size.
App in small window
App in maximized window
What can I do? How can I set the min and max width of the dropdown and still retain the responsiveness of the normal select2 dropdown?
EDIT: Requested sidebar code:
<div id="listColumn" class="col-3">
<div class="incident-container">
<div id="incidentsListRow" class="row d-none mb-5">
<div class="col">
<h6>Incidents:</h6>
<hr />
<div class="row no-gutters">
<div class="col" id="incidentsList">
</div>
</div>
</div>
</div>
</div>