zestia / ember-select-box

:capital_abcd: A faux select box for Ember apps
MIT License
64 stars 14 forks source link

Possible issue with keyboard navigation? #11

Closed macgyver closed 7 years ago

macgyver commented 7 years ago

Hey there! This is an awesome addon. I'm investigating an issue and I'm wondering if you could help me figure out if it's a problem with the addon or if I'm just doing something wrong.

Here is a demonstration of the issue (with keyboard viewer so you can see what I'm pressing) esb-cursor-order

To reproduce the issue yourself, just navigate to http://localhost:4200/tag-select2 or whatever and follow these steps:

  1. click on input to open the dropdown
  2. select the first option by clicking on it
  3. delete the selected "tag" by clicking the X or hitting "delete" two times
  4. now use the cursor keys to move the "active" state through the options - note that the order seems weird (first element is "last" in the order)

I know it's quite a bit of code to review.. please let me know if there's anything I can do to make it easier for you to review. Thanks!

amk221 commented 7 years ago

Thanks for the detailed reproduction!

Try this: {{#each _options key='@index' as |option|}} Reason why: http://emberjs.com/api/classes/Ember.Templates.helpers.html#toc_specifying-keys

macgyver commented 7 years ago

Woo! that fixes it - I guess I'm surprised that @index isn't the default key. Thanks so much for your help!