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 item selection against manual input #79

Merged
merged 1 commit into from
Nov 18, 2016
Merged

Fix item selection against manual input #79

merged 1 commit into from
Nov 18, 2016

Conversation

StephaneTrebel
Copy link
Contributor

@StephaneTrebel StephaneTrebel commented Nov 18, 2016

Your prototype was working fine except for two issues :

  • The automatic highlight of the first list option is conflicting with user input
  • Selecting an option with Enter caused adding the current user input (For instance if I input "foo" and the list shows "foobar" and then I hit direction keys to select "foobar" and hit Enter, it would cause to add "foo" as a new item)

I fixed them both in this PR by:

  • Making it so the first option is not highlighted by default
  • Reversing the order of detecting the onEnter worklow: First we check for highlighted options and only after the user input.

This should fix (#39)

@dgrammatiko
Copy link
Contributor

Works great!

@jshjohnson jshjohnson merged commit f49c970 into Choices-js:feature/select-add-items Nov 18, 2016
@jshjohnson
Copy link
Collaborator

Love it - thanks for this!

@StephaneTrebel StephaneTrebel deleted the feature/select-add-items branch November 18, 2016 14:12
@StephaneTrebel
Copy link
Contributor Author

No problem, I needed it on my side too so I'm glad I could help us both ^^ 👍

@StephaneTrebel StephaneTrebel restored the feature/select-add-items branch November 21, 2016 13:49
@AbdelrhmanS
Copy link

@dgt41 how this works ?
Do it want custom configuration ?

@dgrammatiko
Copy link
Contributor

@AbdelrhmanS you need to check out https://github.com/jshjohnson/Choices/compare/feature/select-add-items?expand=1
Also you need to add addItem: true or something like that in your config, check that branch's docs

@AbdelrhmanS
Copy link

AbdelrhmanS commented Apr 9, 2017

@dgt41
i had checkout to this branch #79 and add those config

const tagsChoices = new Choices(tagsEl, {
   choices: tagsTpl, // my predefined inputs 
   editItems: true,
   maxItemCount: 5,
   removeItemButton: true,
   duplicateItems: false,
   addItem: true,
});
<!-- my select tag -->
<select class="tags-input" type="text" placeholder="Tags" multiple></select>

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

4 participants