aehlke/tag-it — pull request #158 by davidjb (2013-03-25 04:07:55+00:00)
Title: Fix Tag-it preventing selection of auto-complete values via keyboard

If I configure a page with an standard ```` tag, the latest version of Tag-it and appropriate dependencies, if I try and do:

```
$('input[name="search_term"]').tagit({
allowSpaces: true,
caseSensitive: false,
singleField: true,
autocomplete:
{source: ['one', 'two', 'three'], //typically I use an external source here
delay: 0,
autoFocus: true}
});
```

then Tag-it works, except for when I'm attempting to select an item out of the autocomplete results via hitting tab or enter on the keyboard.

``autoFocus`` is true, so the first item in the results is automatically selected when the autocomplete entries appear. However, after entering some text (eg ``thr``), and hitting the Enter or Tab key, a tag is created with the ``thr`` text, rather than ``three``, which was the entry selected within the autocomplete menu.

This pull request ensures that during the ``keydown`` event, that a tag is only created if autocomplete isn't present/open, as the ``select`` handler for the autocomplete will handle creating the tag for us later. Previously, the ``keydown`` event was prematurely creating a tag from the half-complete input & closing the autocomplete too early.