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 position on every open #8653

Closed
wants to merge 1 commit into from

Conversation

EladBezalel
Copy link
Member

  • menu overlay is only created once and the position of the overlay wasn't calculated again

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 26, 2017
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM, but I'm not sure how this plays in with #7376. AFAIK the position strategies aren't really intended to be overwritten after init. It would be better if we allowed for the position strategy's positions to be updated instead. We have that in the new connected positioning, but I'm not sure whether we should backport it to the current one. cc @jelbourn

@@ -313,6 +313,8 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
const config = this._getOverlayConfig();
this._subscribeToPositions(config.positionStrategy as ConnectedPositionStrategy);
this._overlayRef = this._overlay.create(config);
} else {
Copy link
Member

@crisbeto crisbeto Nov 26, 2017

Choose a reason for hiding this comment

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

Flip the if/else here so it's something like this. It should be a little easier to read through:

if (this._overlayRef) {
  // update position
} else {
  // create overlay
}

- menu overlay is only created once and the position of the overlay wasn't calculated again
@jelbourn
Copy link
Member

This will indeed conflict with #7376, which I plan on getting in first

@EladBezalel
Copy link
Member Author

@jelbourn than let's wait with this and #8655 until it get's in

crisbeto added a commit to crisbeto/material2 that referenced this pull request Dec 4, 2017
… init

Backports the ability to update a connected overlay's positioning from the new flexible connected position strategy. This helps facilitate cases like angular#8653 without having to overwrite the entire position strategy.
@crisbeto
Copy link
Member

crisbeto commented Dec 4, 2017

Thinking about this one again, I think that overwriting the position strategy can cause some subtle bugs, because it means that any subscriptions to the onPositionChange will be broken once the new strategy is assigned. I've submitted #8800 that allows for the positions to be updated instead.

andrewseguin pushed a commit that referenced this pull request Dec 13, 2017
… init (#8800)

Backports the ability to update a connected overlay's positioning from the new flexible connected position strategy. This helps facilitate cases like #8653 without having to overwrite the entire position strategy.
andrewseguin pushed a commit to andrewseguin/components that referenced this pull request Dec 19, 2017
… init (angular#8800)

Backports the ability to update a connected overlay's positioning from the new flexible connected position strategy. This helps facilitate cases like angular#8653 without having to overwrite the entire position strategy.
@jelbourn
Copy link
Member

Closing this since (based on the comments) we'd want to do a different approach.

@jelbourn jelbourn closed this Jan 24, 2018
@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
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.

4 participants