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

Fix Tag-it preventing selection of auto-complete values via keyboard #158

Closed
wants to merge 1 commit into from

Conversation

davidjb
Copy link

@davidjb davidjb commented Mar 25, 2013

If I configure a page with an standard <input> 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.

@grigoryk
Copy link

Seeing similar behaviour and this PR seems to do the trick. Thanks, @davidjb!

@bftanase
Copy link

bftanase commented Apr 3, 2013

Awesome! Seem to work fine for me too. @aehlke any chance of merging this PR? Please? Pretty please? :)

@aehlke aehlke closed this in d416408 Apr 27, 2013
@aehlke
Copy link
Owner

aehlke commented Apr 27, 2013

thanks!

@alovak
Copy link

alovak commented Jun 26, 2013

@aehlke with this PR was broken behavior that I expected to get :)

As @davidjb said:

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.

What if I wanted to enter just 'thr'?

With this update I can't create a tag that is a subset of existed tag :(

@jpotterm
Copy link

@alovak I'm having the same problem as you. This pull request creates a regression and prevents the creation of new tags while the autocomplete menu is open. I've submitted a fix here: #202.

@alovak
Copy link

alovak commented Aug 21, 2013

@jpotterm thanks for notifying me :)

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.

None yet

6 participants