Skip to content

Conversation

@atomicpages
Copy link

@atomicpages atomicpages commented Feb 6, 2017

Ran into an issue where I had an input field determine which items which be added to the selected box. The focus method was causing the input field to lose focus. See the following case:

<input type="email" placeholder="user@foo.com">
<select id="shuttle">
  <option value="a@foo.com">a@foo.com</option>
  <option value="b@foo.com">b@foo.com</option>
  <option value="c@foo.com">c@foo.com</option>
</select>
function foo() {
  var prev = '';
  $('input[type="email"]').on('keyup', function (e) {
    if ($(e.target).val() !== prev) {
      $shuttle.multiSelect('deselect_all'); // caused a focus change and bad UX
      // ...
    }
  }).on('focus', function (e) {
    prev = $(e.target).val();
  });
}

I don't think focusing on the shuttle after other of these method invocations is necessary.

Note: Test compiled + all unit tests passed.

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

Successfully merging this pull request may close these issues.

1 participant