capybara_select2
capybara_select2 copied to clipboard
Select2 with tag is using a textarea for the search input rather than an input
I'm using a select2 element with the tag option. When I use select2 'something', from: 'Something', tag: true
I get the error:
Capybara::ElementNotFound:
Unable to find css ".select2-container--open input.select2-search__field" within #<Capybara::Node::Element tag="body" path="/HTML/BODY[1]">
When I look at the code on the page, the .select2-search__field
element is a textarea rather than an input. I think that's reflected in the select2 code here
I think additional search input selectors are needed. If I add this before select2
call:
CapybaraSelect2::Selectors::SearchInputSelectors = {'4' => ".select2-container--open textarea.select2-search__field" }
The test runs without error.
I believe this change to CapybaraSelect2::Selectors::SearchInputSelectors
will fix the problem:
SearchInputSelectors = {
'2' => ".select2-dropdown-open input.select2-focused",
'3' => ".select2-drop-active input.select2-input," + # single
".select2-dropdown-open input.select2-input", # multi
'4' => ".select2-container--open input.select2-search__field," +
".select2-container--open textarea.select2-search__field"
}.freeze
With what version of select2 plugin do you see this error, @reggieb?