Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was 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

Description

@jwmay2012

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)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions