Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select2 with tag is using a textarea for the search input rather than an input #27

Open
reggieb opened this issue Sep 23, 2021 · 2 comments

Comments

@reggieb
Copy link

reggieb commented Sep 23, 2021

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.

@reggieb
Copy link
Author

reggieb commented Sep 23, 2021

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

@Hirurg103
Copy link
Owner

With what version of select2 plugin do you see this error, @reggieb?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants