indrimuska / angular-selector

A native AngularJS directive that transform a simple <select> box into a full html select with typeahead.
http://indrimuska.github.io/angular-selector
MIT License
96 stars 36 forks source link

Selected Item not highlighted on the list #54

Closed shanmugam-siva closed 8 years ago

shanmugam-siva commented 8 years ago

Hi I am using this component. It works great. I have an issue highlighting the selected item on the list. When you select an item using your mouse or up /down arrow, the selected item is highlighted when you open the list again but when you select the item by typing complete text and enter key always first item in the list is highlighted when you open the list again.

Could you please help to resolve the issue?

indrimuska commented 8 years ago

Hi @shanmugam-siva, to have the behavior you want it needs a bit of time to code a solution.

The main problem is that when you filter the list (by typing something) filteredOptions array contains less (or equals) values than the full options array. Since the highlighted index refers to the filtered array, you need to find the index of the selected option in the original options array, in order to set the new highlighted value after hitting Enter.

If you like to propose a PR I'll be glad to help you and review it for you! :)

shanmugam-siva commented 8 years ago

Thanks. I am trying to create new pull request with changes on my local branch but I don't have sufficient permission.

indrimuska commented 8 years ago

First fork the project: https://help.github.com/articles/fork-a-repo/

git clone https://github.com/<your-username>/angular-selector

Then, just create a new branch from the master branch:

git checkout -b <topic-branch-name>

or use the GitHub desktop application:

schermata 2016-07-06 alle 17 20 26

Last, but not least, create a pull request: https://github.com/indrimuska/angular-selector/pull/new/master