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(cdk/overlay): skip trigger interactions in outside click event #29044

Merged
merged 1 commit into from
May 14, 2024

Conversation

crisbeto
Copy link
Member

Adds some logic to skip the trigger when considering clicks outside of the overlay since filtering them is the most common case (e.g. we do it in some of our components) and can be annoying to deal with.

Fixes #28949.

@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label May 14, 2024
@crisbeto crisbeto requested a review from jelbourn as a code owner May 14, 2024 09:08
const origin = this._getOriginElement();
const target = _getEventTarget(event) as Element | null;

if (!target || !origin || (origin !== target && !origin.contains(target))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the null checks appear to be redundant since contains returns false if target is null. This could be reduced to origin !== target && !origin?.contains(target))

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll get rid of the target check, but I'll leave in the one for origin since I don't want to end up comparing nulls.

Adds some logic to skip the trigger when considering clicks outside of the overlay since filtering them is the most common case (e.g. we do it in some of our components) and can be annoying to deal with.

Fixes angular#28949.
@crisbeto crisbeto force-pushed the 28949/overlay-outside-click branch from 68d7028 to b868d9e Compare May 14, 2024 16:16
@crisbeto crisbeto self-assigned this May 14, 2024
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label May 14, 2024
@crisbeto crisbeto merged commit 33b6fc1 into angular:main May 14, 2024
24 of 26 checks passed
crisbeto added a commit that referenced this pull request May 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…29044)

Adds some logic to skip the trigger when considering clicks outside of the overlay since filtering them is the most common case (e.g. we do it in some of our components) and can be annoying to deal with.

Fixes #28949.

(cherry picked from commit 33b6fc1)
crisbeto added a commit that referenced this pull request May 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…29044)

Adds some logic to skip the trigger when considering clicks outside of the overlay since filtering them is the most common case (e.g. we do it in some of our components) and can be annoying to deal with.

Fixes #28949.

(cherry picked from commit 33b6fc1)
@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 Jun 14, 2024
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: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(cdk overlay): open/close overlay behavior
2 participants