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(menu): update to use overlay backdrop #1534

Merged
merged 1 commit into from
Oct 21, 2016

Conversation

kara
Copy link
Contributor

@kara kara commented Oct 19, 2016

Closes #1360, #1499, #1506 .

r: @jelbourn

@kara kara added pr: needs review blocked This issue is blocked by some external factor, such as a prerequisite PR labels Oct 19, 2016
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 19, 2016
@kara kara added pr: needs rebase and removed blocked This issue is blocked by some external factor, such as a prerequisite PR labels Oct 19, 2016
@@ -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());
Copy link
Member

Choose a reason for hiding this comment

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

Unit test?

Copy link
Contributor Author

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?

Copy link
Contributor

@fxck fxck Oct 20, 2016

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/

Copy link
Member

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.

Copy link
Contributor

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.

@jelbourn
Copy link
Member

LGTM

@kara kara added the action: merge The PR is ready for merge by the caretaker label Oct 20, 2016
@jelbourn
Copy link
Member

Looks like you might have to .trim() your textContent for mobile safari

@jelbourn jelbourn removed the action: merge The PR is ready for merge by the caretaker label Oct 20, 2016
@kara kara force-pushed the click-catcher branch 7 times, most recently from 40602e1 to df1d455 Compare October 21, 2016 20:31
@kara kara added the action: merge The PR is ready for merge by the caretaker label Oct 21, 2016
@kara
Copy link
Contributor Author

kara commented Oct 21, 2016

@jelbourn Finally passing.

@kara kara force-pushed the click-catcher branch 2 times, most recently from a6ab256 to 35eee37 Compare October 21, 2016 22:21
@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 6, 2019
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 cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue : multiple md-menu opened at the same time
4 participants