Skip to content

Commit

Permalink
Fix issue when fill select2 input when it's already open
Browse files Browse the repository at this point in the history
  • Loading branch information
jdecool committed Dec 20, 2017
1 parent fee41ab commit b5349bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Context/Select2Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public function iShouldSeeSelectChoices($field, $num)
*/
private function openField(DocumentElement $page, $field)
{
// force select2 to be closed
$page->find('css', 'body')->press();

$fieldName = sprintf('select[name="%s"] + .select2-container', $field);

$inputField = $page->find('css', $fieldName);
Expand Down
9 changes: 9 additions & 0 deletions tests/features/select2.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ Feature: Select2 Feature
Scenario:
Given I am on "/select2-ajax.html"
Then I fill in select2 "select_number" with "France" and wait 6 seconds until results are loaded

@javascript
Scenario: Test fill select2 if list already open
Given I am on "/select2.html"
When I fill in select2 input "select_number" with "F"
Then I should see 2 choice in select2 "select_number"

When I fill in select2 input "select_number" with "F"
Then I fill in select2 "select_number" with "Four"

0 comments on commit b5349bd

Please sign in to comment.