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

bug(MatAutocompleteTrigger): callback applied to closed EventEmitter runs outside of the Angular Zone on outside click #24811

Closed
1 task
br-kwon opened this issue Apr 20, 2022 · 2 comments · Fixed by #24817
Labels
area: material/autocomplete P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@br-kwon
Copy link

br-kwon commented Apr 20, 2022

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

The callback applied to the closed EventEmitter seems to run outside of the Angular Zone when closed is emitted via "outside click"

Reproduction

https://stackblitz.com/edit/components-issue-83t6vu?file=src/app/autocomplete.component.ts

Steps to reproduce:

  1. click inside input - should open panel and disable button
  2. click outside panel to close it - expect button to be enabled, but remains disabled

Expected Behavior

clicking outside the panel to close the panel should have disabled the button without using ngZone.run()

Actual Behavior

the button remains disabled

Environment

  • Angular: 13.3.0
  • CDK/Material: 13.3.0
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS
@br-kwon br-kwon added the needs triage This issue needs to be triaged by the team label Apr 20, 2022
@br-kwon br-kwon changed the title bug(MatAutocompleteTrigger): panelClosingActions() emits outside of the Angular Zone on click outside bug(MatAutocompleteTrigger): closed EventEmitter emits outside of the Angular Zone on click outside Apr 21, 2022
@br-kwon br-kwon changed the title bug(MatAutocompleteTrigger): closed EventEmitter emits outside of the Angular Zone on click outside bug(MatAutocompleteTrigger): callback applied to closed EventEmitter emits outside of the Angular Zone on outside click Apr 21, 2022
@br-kwon br-kwon changed the title bug(MatAutocompleteTrigger): callback applied to closed EventEmitter emits outside of the Angular Zone on outside click bug(MatAutocompleteTrigger): callback applied to closed EventEmitter runs outside of the Angular Zone on outside click Apr 21, 2022
@br-kwon
Copy link
Author

br-kwon commented Apr 21, 2022

looks like the root cause comes from _subscribeToClosingActions() when the pipe switchMaps to this.panelClosingActions. since this.panelClosingActions is implemented as a getter, it gets evaluated when we're outside of Angular Zone (when firstStable emits).

volvachev added a commit to volvachev/components that referenced this issue Apr 21, 2022
Fixes a bug in Angular Material `autocomplete` when outside click doesn't trigger `changeDetection`.

Fixes angular#24811
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent has pr area: material/autocomplete and removed needs triage This issue needs to be triaged by the team labels Apr 22, 2022
volvachev added a commit to volvachev/components that referenced this issue Apr 22, 2022
Fixes a bug in Angular Material `autocomplete` when outside click doesn't trigger `changeDetection`.

Fixes angular#24811
volvachev added a commit to volvachev/components that referenced this issue Apr 22, 2022
Fixes a bug in Angular Material `autocomplete` when outside click doesn't trigger `changeDetection`.

Fixes angular#24811
volvachev added a commit to volvachev/components that referenced this issue Apr 22, 2022
Fixes a bug in Angular Material `autocomplete` when outside click doesn't trigger `changeDetection`.

Fixes angular#24811
volvachev added a commit to volvachev/components that referenced this issue Apr 22, 2022
Fixes a bug in Angular Material `autocomplete` when outside click doesn't trigger `changeDetection`.

Fixes angular#24811
andrewseguin pushed a commit that referenced this issue Apr 22, 2022
Fixes a bug in Angular Material `autocomplete` when outside click doesn't trigger `changeDetection`.

Fixes #24811
andrewseguin pushed a commit that referenced this issue Apr 22, 2022
Fixes a bug in Angular Material `autocomplete` when outside click doesn't trigger `changeDetection`.

Fixes #24811

(cherry picked from commit 4e5e286)
@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 May 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/autocomplete P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants