Visitar URL original
feat(material/autocomplete): add the ability to auto-select the active option while navigating by crisbeto · Pull Request #20699 · angular/components · GitHub
The Wayback Machine - https://web.archive.org/web/20220321101822/https://github.com/angular/components/pull/20699
Skip to content
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

feat(material/autocomplete): add the ability to auto-select the active option while navigating #20699

Merged
merged 1 commit into from Feb 25, 2022

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 1, 2020

Adds the autoSelectActiveOption input to mat-autocomplete which allows the consumer to opt into the behavior where the autocomplete will assign the active option value as the user is navigating through the list. The value is only propagated to the model once the panel is closed.

There are a couple of UX differences when the new option is enabled:

  1. If the user presses escape while there's a pending auto-selected option, the value is reverted to the last text they typed before they started navigating.
  2. If the user clicks away, tabs away or presses enter while there's a pending option, it will be selected.

The aforementioned UX differences are based on the Google search autocomplete and one of the examples from the W3C here:
https://www.w3.org/TR/wai-aria-practices-1.1/examples/combobox/aria1.1pattern/listbox-combo.html

demo

@crisbeto crisbeto force-pushed the autocomplete-auto-select branch 2 times, most recently from b905ccb to 183b199 Compare Oct 5, 2020
@jelbourn
Copy link
Member

@jelbourn jelbourn commented Oct 8, 2020

Overall looks good. Could we also add this option to MatAutocompleteDefaultOptions?

@Totati
Copy link

@Totati Totati commented Oct 9, 2020

Overall looks good. Could we also add this option to MatAutocompleteDefaultOptions?

Hi, he added it :)
https://github.com/angular/components/pull/20699/files#diff-c584c9b0de57f44162cd166185db2d41R79

@jelbourn
Copy link
Member

@jelbourn jelbourn commented Oct 9, 2020

I somehow glossed right over that

Copy link
Member

@jelbourn jelbourn left a comment

LGTM

@jelbourn
Copy link
Member

@jelbourn jelbourn commented Oct 9, 2020

@crisbeto just needs a rebase

@crisbeto crisbeto force-pushed the autocomplete-auto-select branch from 183b199 to ba613eb Compare Oct 9, 2020
@crisbeto crisbeto force-pushed the autocomplete-auto-select branch from ba613eb to c8f2b3a Compare Nov 9, 2020
@crisbeto crisbeto force-pushed the autocomplete-auto-select branch from c8f2b3a to 7998f3a Compare Dec 6, 2020
@crisbeto crisbeto force-pushed the autocomplete-auto-select branch from 7998f3a to 6d5c3b9 Compare Apr 24, 2021
@zarend
Copy link
Collaborator

@zarend zarend commented Jul 29, 2021

Hi @crisbeto , could you please resolve the merge conflict so I can run a fresh presubmit for this. I couldn't find the previous presubmit. This looks to me like it should be safe because the option we added is off by default 🤞 .

@crisbeto
Copy link
Member Author

@crisbeto crisbeto commented Jul 29, 2021

Rebased.

@crisbeto crisbeto force-pushed the autocomplete-auto-select branch from 6d5c3b9 to 716fdec Compare Jul 29, 2021
@crisbeto crisbeto requested a review from as a code owner Jul 29, 2021
@zarend
Copy link
Collaborator

@zarend zarend commented Jul 29, 2021

…e option while navigating

Adds the `autoSelectActiveOption` input to `mat-autocomplete` which allows the
consumer to opt into the behavior where the autocomplete will assign the active
option value as the user is navigating through the list. The value is only propagated
to the model once the panel is closed.

There are a couple of UX differences when the new option is enabled:
1. If the user presses escape while there's a pending auto-selected option, the value
is reverted to the last text they typed before they started navigating.
2. If the user clicks away, tabs away or presses enter while there's a pending option,
it will be selected.

The aforementioned UX differences are based on the Google search autocomplete and
one of the examples from the W3C here:
https://www.w3.org/TR/wai-aria-practices-1.1/examples/combobox/aria1.1pattern/listbox-combo.html
@crisbeto crisbeto force-pushed the autocomplete-auto-select branch from 22534f4 to 124d442 Compare Feb 25, 2022
@crisbeto crisbeto merged commit b90d942 into angular:master Feb 25, 2022
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants