Skip to content

fix(material/autocomplete): always emit closed event #24642

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

Merged
merged 1 commit into from
Mar 25, 2022

Conversation

mhaertwig
Copy link
Contributor

Currently, the autocomplete does not emit a closed event if the user clicks outside the input field after having entered a string that did not match any option. Moreover, when entering a valid string after an invalid one, the opened event is emitted again without a previous closed event.

autocomplete-no-closed.mp4

Demo: https://stackblitz.com/edit/angular-dvitxy?file=src/app/autocomplete-auto-active-first-option-example.html

This PR ensures that a closed event is emitted every time the panel is closed.

@mhaertwig mhaertwig requested a review from crisbeto as a code owner March 22, 2022 13:34
Currently, the autocomplete does not emit a `closed` event if the user clicks outside the input field after having entered a string that did not match any option. Moreover, when entering a valid string after an invalid one, the `opened` event is emitted again without a previous `closed` event. This PR ensures that a `closed` event is emitted every time the panel is closed
@mhaertwig mhaertwig force-pushed the fix-autocomplete-events branch from 857527d to 5e707d5 Compare March 22, 2022 15:30
Copy link
Contributor

@andrewseguin andrewseguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems right to me (and thanks for adding the tests), but I suspect this may break some tests internally due to expectations on when the events are fired

@andrewseguin andrewseguin added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Mar 24, 2022
@andrewseguin andrewseguin merged commit cb206be into angular:master Mar 25, 2022
forsti0506 pushed a commit to forsti0506/components that referenced this pull request Apr 3, 2022
Currently, the autocomplete does not emit a `closed` event if the user clicks outside the input field after having entered a string that did not match any option. Moreover, when entering a valid string after an invalid one, the `opened` event is emitted again without a previous `closed` event. This PR ensures that a `closed` event is emitted every time the panel is closed
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants