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

fix(material/autocomplete): prevent outside clicks from going to other overlays #25243

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Jul 9, 2022

Adds a subscription to the outside click stream of the autocomplete overlay so that the events don't propagate to other overlays which may close the autocomplete prematurely.

Fixes #25238.

@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 Jul 9, 2022
@crisbeto crisbeto requested a review from mmalerba July 9, 2022 07:02
@crisbeto crisbeto force-pushed the 25238/autocomplete-outside-click branch 3 times, most recently from 0a20257 to d02594f Compare July 9, 2022 19:34
…r overlays

Adds a subscription to the outside click stream of the autocomplete overlay so that the events don't propagate to other overlays which may close the autocomplete prematurely.

Fixes angular#25238.
@crisbeto crisbeto force-pushed the 25238/autocomplete-outside-click branch from d02594f to 5458afc Compare July 9, 2022 19:42
// Subscribe to the pointer events stream so that it doesn't get picked up by other overlays.
// TODO(crisbeto): we should switch `_getOutsideClickStream` eventually to use this stream,
// but the behvior isn't exactly the same and it ends up breaking some internal tests.
overlayRef.outsidePointerEvents().subscribe();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not following what this does - why does adding this subscription change any behavior? What's the side-effect of subscribing?

Copy link
Member Author

@crisbeto crisbeto Jul 11, 2022

Choose a reason for hiding this comment

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

The outside click dispatcher keeps a stack of the open overlays. Whenever a click event happens, it starts from the top of the stack and works its way down until it finds an overlay that has any subscribers to outsidePointerEvents so that it can dispatch the event to it. This was a problem for the autocomplete, because it handles outside clicks internally, instead of going through the dispatcher which meant that it would get skipped over when determining which overlay is on top. The proper fix would be to use the dispatcher, but last time I tried it was somewhat breaking since the autocomplete existed much earlier than the dispatcher.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha thanks

@devversion devversion removed their request for review July 12, 2022 12:01
@andrewseguin andrewseguin added the action: merge The PR is ready for merge by the caretaker label Jul 19, 2022
@crisbeto crisbeto self-assigned this Jul 19, 2022
@crisbeto crisbeto merged commit 8ef59d5 into angular:main Jul 20, 2022
crisbeto added a commit that referenced this pull request Jul 20, 2022
…r overlays (#25243)

Adds a subscription to the outside click stream of the autocomplete overlay so that the events don't propagate to other overlays which may close the autocomplete prematurely.

Fixes #25238.

(cherry picked from commit 8ef59d5)
crisbeto added a commit that referenced this pull request Jul 20, 2022
…r overlays (#25243)

Adds a subscription to the outside click stream of the autocomplete overlay so that the events don't propagate to other overlays which may close the autocomplete prematurely.

Fixes #25238.

(cherry picked from commit 8ef59d5)
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Jul 24, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@angular/cdk](https://github.com/angular/components) | dependencies | patch | [`14.0.5` -> `14.0.6`](https://renovatebot.com/diffs/npm/@angular%2fcdk/14.0.5/14.0.6) |
| [@angular/material](https://github.com/angular/components) | dependencies | patch | [`14.0.5` -> `14.0.6`](https://renovatebot.com/diffs/npm/@angular%2fmaterial/14.0.5/14.0.6) |

---

### Release Notes

<details>
<summary>angular/components</summary>

### [`v14.0.6`](https://github.com/angular/components/blob/HEAD/CHANGELOG.md#&#8203;1406-chromium-pinball-2022-07-20)

[Compare Source](angular/components@14.0.5...14.0.6)

##### material

| Commit | Type | Description |
| -- | -- | -- |
| [cc510216a](angular/components@cc51021) | fix | **autocomplete:** prevent outside clicks from going to other overlays ([#&#8203;25243](angular/components#25243)) |
| [b73b2fb85](angular/components@b73b2fb) | fix | **checkbox:** incorrect animation state when going from pre-checked to indeterminate ([#&#8203;25297](angular/components#25297)) |
| [e7b359286](angular/components@e7b3592) | fix | **slider:** add cancelable checks to touchmove and touchend events ([#&#8203;25301](angular/components#25301)) |
| [d7e422668](angular/components@d7e4226) | fix | **tabs:** disable tab label color transition when animations are disabled ([#&#8203;25308](angular/components#25308)) |

##### material-experimental

| Commit | Type | Description |
| -- | -- | -- |
| [43bfbac51](angular/components@43bfbac) | fix | **mdc-slider:** thumb incorrectly positioned when inside an overlay ([#&#8203;25288](angular/components#25288)) |

#### Special Thanks

Alka Vats, John Vandenberg, Kristiyan Kostadinov and Oliver Kierepka

<!-- CHANGELOG SPLIT MARKER -->

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMTkuMiIsInVwZGF0ZWRJblZlciI6IjMyLjExOS4yIn0=-->

Co-authored-by: cabr2-bot <[email protected]>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1469
Reviewed-by: Epsilon_02 <[email protected]>
Co-authored-by: Calciumdibromid Bot <[email protected]>
Co-committed-by: Calciumdibromid Bot <[email protected]>
@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 Aug 20, 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 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(material-autocomplete): (overlayOutsideClick) condradicts with (optionSelected)
2 participants