Components: Menu positioning going wrong on scroll

Created on 16 May 2018  路  16Comments  路  Source: angular/components

Bug, feature request, or proposal:
Bug

What is the expected behavior?
Menu should stay where initiated

What is the current behavior?
Menu moves down, away from initiated position

What are the steps to reproduce?
https://stackblitz.com/edit/angular-gxkc8e

Click the menu and scroll down with displayed menu

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

Which versions of Angular, Material, OS, TypeScript, browsers are affected?
"@angular/core": "^6.0.0", "@angular/cli": "~6.0.1", "@angular/material": "^6.0.2", "@angular/cdk": "^6.0.2"

G P2 has pr

Most helpful comment

Looks like @crisbeto has a PR open for this but it's been open for almost a month. Who's on PR duty this week? MERGE IT!

All 16 comments

Any workaround for this?

Reopening since we had to revert the fix.

Looks like @crisbeto has a PR open for this but it's been open for almost a month. Who's on PR duty this week? MERGE IT!

@crisbeto This is quite a serious bug. Any possibility this can be fixed in the next release?

The PR is marked as being important, but it does affect a lot of components which makes it harder to merge.

Reopening because we had to revert the fix again. Fix is resubmitted as #12624.

Im using "@angular/material": "^6.4.7" issue still there on a fixed bottom nav

PD: seems like a Google Chrome issue, working well on other browsers

Same issue here but on ALL other browsers except Chrome.
If you open the menu and scroll the menu moves even outside the viewport.

The problem exists also in docs page.
But it is always replicaable if you host the menu in a fixed positioned item.

In that case the solution is to set position fixed to .mat-menu-panel and set the offset etc to your preferences. This is the way I solved it for my app.

I've found closing on scroll somewhat fixes the issue:
@ViewChild(MatMenuTrigger) trigger: MatMenuTrigger;
window.addEventListener('scroll', this.scroll, true)

scroll = (): void => { this.trigger.closeMenu(); } };

I still have this problem in 7.3.3!

I am having this issue too. the more annoying part is that the menu doesn't show in the viewport at all if the user is scrolled down at all. So, @peterhogg 's workaround won't work in that case. It's been 18 days since the last comment and we all need a fix

Same issue here. When scrolling down on a mobile device the closed mat-menu pops up. Really very annoying. We are using Angular 7.2.2.

using angular 7.2.6, angular material and cdk 7.2.0 works finally (i had to downgrade material and cdk to 7.2.0 to avoid the bug - in my case in MatTooltip positioning on the bottom part of the mobile screen.)

Upgraded to latest angular material and it worked

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theunreal picture theunreal  路  3Comments

LoganDupont picture LoganDupont  路  3Comments

constantinlucian picture constantinlucian  路  3Comments

jelbourn picture jelbourn  路  3Comments

savaryt picture savaryt  路  3Comments