fix(menu): update to use overlay backdrop#1534
Conversation
| if (!this._menuOpen) { | ||
| this._createOverlay(); | ||
| this._overlayRef.attach(this._portal); | ||
| this._overlayRef.backdropClick().subscribe(() => this.closeMenu()); |
There was a problem hiding this comment.
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.
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.
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.
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