Skip to content

fix(material/autocomplete): not closing when clicking outside while propagation is stopped #17381

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 12, 2019

Fixes the autocomplete panel not closing if the user clicks outside on an element that stops propagation of the click event (e.g. a mat-chip).

Fixes #17352.

Caretaker note (crisbeto): ~30 screenshot failures, handful of unit test failures testing for old behaviour

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release labels Oct 12, 2019
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 12, 2019
jelbourn
jelbourn previously approved these changes Oct 16, 2019
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Oct 16, 2019
@crisbeto crisbeto force-pushed the 17352/autocomplete-click-outside-capturing branch from a67c5aa to 9721022 Compare July 5, 2020 16:50
@mmalerba mmalerba removed the lgtm label Jul 31, 2020
@crisbeto crisbeto force-pushed the 17352/autocomplete-click-outside-capturing branch from 9721022 to fc31804 Compare August 21, 2020 21:19
@crisbeto crisbeto changed the title fix(autocomplete): not closing when clicking outside while propagation is stopped fix(material/autocomplete): not closing when clicking outside while propagation is stopped Jan 4, 2021
@crisbeto crisbeto force-pushed the 17352/autocomplete-click-outside-capturing branch from fc31804 to 5fa2d4c Compare January 4, 2021 21:08
@crisbeto crisbeto force-pushed the 17352/autocomplete-click-outside-capturing branch from 5fa2d4c to 0d20156 Compare February 14, 2021 12:53
@andrewseguin andrewseguin added needs rebase and removed cla: yes PR author has agreed to Google's Contributor License Agreement labels Dec 28, 2021
…ropagation is stopped

Fixes the autocomplete panel not closing if the user clicks outside on an element that
stops propagation of the `click` event (e.g. a `mat-chip`).

Fixes angular#17352.
@crisbeto crisbeto force-pushed the 17352/autocomplete-click-outside-capturing branch from 0d20156 to 749d3ba Compare March 19, 2022 08:43
@andrewseguin andrewseguin removed the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Mar 28, 2022
@andrewseguin andrewseguin assigned crisbeto and unassigned crisbeto Apr 22, 2022
@mmalerba mmalerba self-assigned this May 6, 2022
@mmalerba
Copy link
Contributor

mmalerba commented May 6, 2022

It seems like this introduced a new bug where autocompletes can escape being closed. Here's how to reproduce:

  1. Go to the dev app autocomplete page
  2. Get some references to 2 different autocomplete input elements and save them as first and second
  3. In the console run: setTimeout(() => {first.focus(); second.click()}, 1000), and then quickly click in the page before setTimeout triggers
  4. Notice both autocomplete panels wind up open at the same time. This scenario may appear rather artificial, but someone could do this programmatically in a real app (and several teams in google are doing it in their test code).

I suspect its something to do with the timing / order of the events now that we changed the click handler to the capture phase, maybe adding a setTimeout(0) delay will help?

@mmalerba mmalerba removed the action: merge The PR is ready for merge by the caretaker label May 6, 2022
@mmalerba mmalerba removed their assignment May 23, 2022
@NsdHSO
Copy link

NsdHSO commented Nov 14, 2022

@crisbeto does this problem still exist?

@crisbeto
Copy link
Member Author

It does, but I haven't had time to come back and try to land this change.

@NsdHSO
Copy link

NsdHSO commented Nov 14, 2022

@crisbeto do you know when it would be feasible to have it in release??

@josephperrott josephperrott requested a review from a team as a code owner December 18, 2024 17:40
@josephperrott josephperrott requested review from amysorto and mmalerba and removed request for a team December 18, 2024 17:40
@mmalerba mmalerba removed their request for review February 20, 2025 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autocomplete dropdown opened after losing focus
6 participants