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

Access to DOM click event on Overlay backdropClicked emitter #9713

Closed
Bradleycorn opened this issue Jan 31, 2018 · 3 comments · Fixed by #9716
Closed

Access to DOM click event on Overlay backdropClicked emitter #9713

Bradleycorn opened this issue Jan 31, 2018 · 3 comments · Fixed by #9716
Assignees
Labels
P4 A relatively minor issue that is not relevant to core functions

Comments

@Bradleycorn
Copy link

Bug, feature request, or proposal:

Feature Request

What is the expected behavior?

When using an Overlay from the CDK and the user clicks on the backdrop return the underlying DOM click event to backdropClicked() subscribers. This is useful in some scenarios where we might need to do something like event.preventDefault();

What is the current behavior?

The backdropClicked() event emitter doesn't include the dom click event when it emits (it emits null),

https://github.com/angular/material2/blob/master/src/cdk/overlay/overlay-ref.ts#L279-L281

    // Forward backdrop clicks such that the consumer of the overlay can perform whatever
    // action desired when such a click occurs (usually closing the overlay).
    this._backdropElement.addEventListener('click', () => this._backdropClick.next(null));

What are the steps to reproduce?

Create an Overlay, and subscribe to it's BackdropClicked() event emitter. Click on the backdrop, and see that the next callback receives null instead of the dom click event.

What is the use-case or motivation for changing an existing behavior?

It may be useful to stopPropigation() or preventDefault() when clicking on the backdrop of an overlay. But we can't do that if the DOM event for the click is not passed on to the backdropClicked() subscriber.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 5.2.2, CDK v5.1.0

Is there anything else we should know?

@crisbeto crisbeto self-assigned this Jan 31, 2018
@crisbeto crisbeto added has pr P4 A relatively minor issue that is not relevant to core functions labels Jan 31, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Jan 31, 2018
Exposes the click event object when subscribing to the `OverlayRef.backdropClick` stream.

Fixes angular#9713.
tinayuangao pushed a commit that referenced this issue Feb 1, 2018
Exposes the click event object when subscribing to the `OverlayRef.backdropClick` stream.

Fixes #9713.
@Bradleycorn
Copy link
Author

Wow, that was fast! Thanks!

mmalerba pushed a commit to mmalerba/components that referenced this issue Feb 1, 2018
Exposes the click event object when subscribing to the `OverlayRef.backdropClick` stream.

Fixes angular#9713.
@Daeluse
Copy link

Daeluse commented Feb 7, 2018

Shouldn't the CdkConnectedOverlay directive be update to support this as well?

crisbeto added a commit to crisbeto/material2 that referenced this issue Feb 8, 2018
…ective

Exposes the `MouseEvent` from the backdrop click in the `ConnectedOverlayDirective.backdropClick` emitter.

Relates to angular#9713.
jelbourn pushed a commit that referenced this issue Feb 12, 2018
…ective

Exposes the `MouseEvent` from the backdrop click in the `ConnectedOverlayDirective.backdropClick` emitter.

Relates to #9713.
jelbourn pushed a commit that referenced this issue Feb 13, 2018
…ective (#9845)

Exposes the `MouseEvent` from the backdrop click in the `ConnectedOverlayDirective.backdropClick` emitter.

Relates to #9713.
andrewseguin pushed a commit that referenced this issue Feb 20, 2018
…ective (#9845)

Exposes the `MouseEvent` from the backdrop click in the `ConnectedOverlayDirective.backdropClick` emitter.

Relates to #9713.
@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 Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants