Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

md-autocomplete Can't select item when searchText equals the one and only item in md-items #1858

Closed
jwmay2012 opened this issue Mar 10, 2015 · 0 comments
Assignees
Milestone

Comments

@jwmay2012
Copy link

If you have a list of items ['foo', 'bar']
and you type 'fo'
'foo' is listed under the input. This is fine.
If you enter 'foo' then the list disappears which is fine too.
BUT from there pressing ENTER does not select the item and initiate md-selected-item-change.
However, if you type 'foo' then press DOWN ARROW then ENTER it will select it properly because the highlighted item index was changed to 0 by pressing DOWN ARROW.
I think it should automatically select the first item in the list when you press ENTER if no item is highlighted (index == -1) and the list has at least one item in it.

https://github.com/angular/material/blame/master/src/components/autocomplete/js/autocompleteController.js#L158-L162

maybe do something like this?
If item list is > 0 and index == -1
select(0)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants