question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select2 inside Bootstrap Modal does not size properly and search does not work

See original GitHub issue

Having the following HTML

<form id="frmFoo" ...>
  <div class="form-group">
    <label for="txtFoo" class="col-sm-2 control-label">Foo Field :</label>
      <div class="col-sm-6">
        <select id="txtFoo" class="form-control" placeholder="Foo Value"></select>
      </div>
    </div>
  </div>
</form>

will not display the <select> element’s width properly as the form-control class is completely ignored when generating the widget’s UI.

** Edit **

Also, there are other discrepancies with Bootstrap’s UI, such as the focus’ borders, that are not respected and cause inconsistent UI.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
yanickrochoncommented, Feb 5, 2015

The solution is to document dropdownParent for the dropdown input search issue. As for the width, I’m not sure what would be the proper way (I have not dug into the sources much since the last major release).

At the moment, I temporarily fix this by manually setting width: 100%; to the <select> element.

0reactions
kevin-browncommented, Feb 10, 2015

The solution is to document dropdownParent

It just hit me that this is already documented.

https://select2.github.io/options.html#dropdownParent

The Bootstrap issue is pretty well documented at https://github.com/select2/select2/issues/600.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common problems - The jQuery replacement for select boxes
Select2 does not function properly when I use it inside a Bootstrap modal. ... This issue occurs because Bootstrap modals tend to steal...
Read more >
Select2 doesn't work when embedded in a bootstrap modal
According to the official select2 documentation this issue occurs because Bootstrap modals tend to steal focus from other elements outside of the ...
Read more >
Select 2 search not clickable in Bootstrap modal - Okler Themes
with select2 inside them. The search field in the select2 isn't clickable so the users can't search within the rows of the select....
Read more >
Select 2 drop-down input search doesn't work inside bootstrap ...
By removing the " tabindex " attribute from the modal. This will allow moving around in the Select2 box, but you lose the...
Read more >
Dropdown is not reachable when element is rendered in modal
Another issue is that when the select2 JS attach behavior runs, the jQuery dialog is not a selectable element with $('.ui-modal') when trying...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found