-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Autocomplete - add option to always treat first option as active #8423
Comments
I don't know how but this exact feature seems to be working in https://teradata.github.io/covalent/#/components/chips (which use material 5 internally). After some research, I did not find any call the methods cited above |
@myagoo Thanks, yes that's as far as I've gotten right now. But if you use the keyboard to navigate up or down in their autocomplete menu, it's not working properly: They're probably doing what I mentioned above - use the |
@crisbeto we have some folks inside Google asking for this (or something close enough). Now that I look at it, I think this is an important feature to add. A good example of the behavior I have in mind is the "Enter action" or "Open file by name" pop-ups in WebStorm; you need to be able to start entering a string and hit enter as soon as your desired match is on top. For API, I'm thinking something like |
…open Adds the ability for the consumer opt-in to having the autocomplete highlight the first option when opened. Includes an injection token that allows it to be configured globally. Fixes angular#8423.
…open Adds the ability for the consumer opt-in to having the autocomplete highlight the first option when opened. Includes an injection token that allows it to be configured globally. Fixes angular#8423.
…open Adds the ability for the consumer opt-in to having the autocomplete highlight the first option when opened. Includes an injection token that allows it to be configured globally. Fixes angular#8423.
…open Adds the ability for the consumer opt-in to having the autocomplete highlight the first option when opened. Includes an injection token that allows it to be configured globally. Fixes angular#8423.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Feature Request
What is the expected behavior?
Should be able to manually/programmatically set the first option in the autocomplete panel as the activeOption, so that it receives the appropriate styles and is selected when the user presses enter.
What is the current behavior?
User must either use the down key or hover with the mouse on the option to make it active.
What are the steps to reproduce?
N/A
What is the use-case or motivation for changing an existing behavior?
Our users are going to be limited to selecting only options from the autocomplete. We're experiencing problems where users are either typing in a partial value or the full value, hitting the enter key, and not understanding why that option isn't being selected.
See attached images
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular - 4.4.6
Material - 2.0.0-beta.12
Is there anything else we should know?
There is a way to select the first option by using
matAutocomplete.options.first.select()
and binding that to thekeyup.enter
event. I can also forcibly set the active styles on the first option by usingmatAutocomplete.options.first.setActiveStyles()
but this doesn't set the first option as theactiveOption
. Without that, the key manager doesn't know that the first option is already highlighted and pressing theDOWN_ARROW
should make the second option active.The typeahead using bootstrap and AngularJS has the exact desired behavior for a working example: https://angular-ui.github.io/bootstrap/#!#typeahead
The text was updated successfully, but these errors were encountered: