-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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(menu): update to use overlay backdrop #1534
Conversation
@@ -70,6 +70,7 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy { | |||
if (!this._menuOpen) { | |||
this._createOverlay(); | |||
this._overlayRef.attach(this._portal); | |||
this._overlayRef.backdropClick().subscribe(() => this.closeMenu()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an e2e that covers this already, but I can add a unit too if you think it will help coverage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be
this._overlayRef.backdropClick().take(1).subscribe(() => this.closeMenu());
to unsubscribe the observer since the backdrop element will be removed from DOM anyway? see https://jsfiddle.net/chy8gLjs/ vs. https://jsfiddle.net/j4p7gq1v/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the backdrop doesn't have anything to do with positioning, I'd do this as a unit tests. We generally want to prefer capturing behaviors with unit tests because they are so much faster.
@fxck I would use .first()
, but yeah that should be the the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing. Anyway I think there's couple more of these potential leaks across the repo. Either not using take/first when it's supposed to happen only once or not unsubscribing on destroy, when it's actually supposed to listen on changes until the component is destroyed. I'll create an issue if I get couple of minutes.
LGTM |
Looks like you might have to |
40602e1
to
df1d455
Compare
@jelbourn Finally passing. |
a6ab256
to
35eee37
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Closes #1360, #1499, #1506 .
r: @jelbourn