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

Menu positioning going wrong on scroll #11365

Closed
frmtlp opened this issue May 16, 2018 · 16 comments · Fixed by #11421, #11628 or #12624
Closed

Menu positioning going wrong on scroll #11365

frmtlp opened this issue May 16, 2018 · 16 comments · Fixed by #11421, #11628 or #12624
Assignees
Labels
G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround

Comments

@frmtlp
Copy link

frmtlp commented May 16, 2018

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"

@crisbeto crisbeto self-assigned this May 16, 2018
@crisbeto crisbeto added P2 The issue is important to a large percentage of users, with a workaround has pr labels May 16, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue May 20, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
crisbeto added a commit to crisbeto/material2 that referenced this issue May 20, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
crisbeto added a commit to crisbeto/material2 that referenced this issue May 23, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
josephperrott pushed a commit that referenced this issue May 30, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes #11365.
@lacolaco
Copy link
Contributor

Any workaround for this?

crisbeto added a commit to crisbeto/material2 that referenced this issue May 31, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
josephperrott pushed a commit that referenced this issue May 31, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes #11365.
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 2, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
@crisbeto
Copy link
Member

crisbeto commented Jun 6, 2018

Reopening since we had to revert the fix.

@crisbeto crisbeto reopened this Jun 6, 2018
andrewseguin pushed a commit that referenced this issue Jun 7, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes #11365.
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 21, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
@sollenne
Copy link

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!

@jsdream
Copy link

jsdream commented Jul 31, 2018

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

@josephperrott josephperrott added the G This is is related to a Google internal issue label Aug 8, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 10, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
@crisbeto
Copy link
Member

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

@crisbeto crisbeto reopened this Aug 10, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 22, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
mmalerba pushed a commit that referenced this issue Aug 23, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes #11365.
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 24, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
jelbourn pushed a commit that referenced this issue Aug 25, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes #11365.
mmalerba pushed a commit that referenced this issue Aug 27, 2018
…nd position locking

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes #11365.
jelbourn pushed a commit that referenced this issue Aug 28, 2018
…nd position locking (#12624)

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes #11365.
@snakone
Copy link

snakone commented Sep 1, 2018

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

@vapits
Copy link

vapits commented Sep 21, 2018

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

@vapits
Copy link

vapits commented Sep 21, 2018

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.

LeonardoGastonRossi pushed a commit to LeonardoGastonRossi/material2 that referenced this issue Sep 22, 2018
…ng to be merge into 6.4.X.

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes angular#11365.
jelbourn pushed a commit that referenced this issue Oct 4, 2018
…e merge into 6.4.X.

* Fixes the position of flexible overlays with pushing enabled being thrown off once the user starts scrolling.
* Fixes flexible overlays with pushing not handling locked positioning. With these changes locked overlays will only be pushed when they're opened, whereas non-locked overlays will stay in the viewport, even when the user scrolls down.
* Fixes a potential issue due to a couple of variables being initialized together where one is set to zero and the other one is undefined.

Fixes #11365.
@peterhogg
Copy link

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(); } };

@rezabay
Copy link

rezabay commented Feb 24, 2019

I still have this problem in 7.3.3!

@jkon
Copy link

jkon commented Mar 13, 2019

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

@sebastianlaag
Copy link

sebastianlaag commented Apr 3, 2019

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.

@harellevy
Copy link

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

@AnshulMahajan10
Copy link

Upgraded to latest angular material and it worked

@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 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.