-
Notifications
You must be signed in to change notification settings - Fork 111
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
Ambiguous match
when there are multiple select2 elements
#41
Comments
Ambiguous match
when there are multiple Ambiguous match
when there are multiple select2 elements
The code in "capybara-select2/gem/lib/capybara-select2.rb" has a section with "if options.has_key? :search" that uses only a find command to select the element, no use of first to resolve the ambiguous matches. |
This can be fixed by having |
So would it be fixed by using a more specific selector when you have two select2s? I.e.
I mean just picking the first one in an ambiguous match is not the right solution IMO. |
In goodwill#37 we changed the `first()` to `find()` but this leads to goodwill#41. This is a fix for the same.
@machisuji What you're saying is probably correct. The older first is just better represented as find(.., match: :first) if we want to keep the old behavior. |
Hmm. I actually agree with @machisuji - it is an ambiguous match, so the current behaviour is correct. I guess it's arguable whether this change is breaking or a bugfix ;) I think if there's a 'fix' to be made at all then it would be to add a message into the error suggesting using the |
I'm having the same issue when I have the
I think this could be fixed by seaching for the search__field in the select2-container:
Note that I have incorporated the fix of @abuisman for properly selecting the result items when using optgroups: #47 |
I had the same issue when I had the
I got around this by monkey patching the gem and adding in the extra class
This worked a charm for me, and haven't investigated if this extra class will work for different versions of select2 but might help others |
#37 changed the code which finds the select2 input from using
first
to usingfind
. Unfortunately Capybara chokes when it can't find a unique element withfind
- which happens when you have more than one select2 element in the page:I don't really understand enough about the issue that #37 fixes to know what the solution should be.
(cc @machisuji)
The text was updated successfully, but these errors were encountered: