material icon indicating copy to clipboard operation
material copied to clipboard

dialog: cuts off/hides body when window is scrolled

Open rgthree opened this issue 11 years ago • 43 comments

Fiddle: http://jsfiddle.net/rgthree/9m7z8cqy/

If body has any overflow applied by the app, angular overrides its style to hidden when the dialog is open. This clashes with the other styles added to body, particularly, position: fixed; top: -XXpx; and max-height: 100% from the md-dialog-is-showing class which ends up cutting off the body content or completely hiding it when the window has scrolled more than 100% the height.

Note, we use body {overflow-x:scroll;} to force a scrollbar and reduce horizontal jitter when page content height changes due to navigation.

rgthree avatar Aug 12 '15 15:08 rgthree

Has anyone been able to solve this. I am having the same issue

lexyfeito avatar Mar 17 '16 16:03 lexyfeito

@zilions were u able to find a fix for this issue?

lexyfeito avatar Mar 17 '16 21:03 lexyfeito

not sure if this is a true fix, but this seemed to do the trick for me: body { overflow-x: visible; }

zuspan avatar Mar 20 '16 21:03 zuspan

@lexyfeito - No fix from me yet. Tried everything in this thread and nothing seems to work well.

zilions avatar Mar 21 '16 08:03 zilions

@zilions same here this is getting really annoying

lexyfeito avatar Mar 21 '16 12:03 lexyfeito

@zilions hey so after reading @abouillon comment i set the body overflow: initial; and it seems to fixed the problem.

lexyfeito avatar Mar 21 '16 12:03 lexyfeito

@lexyfeito That's what I was going to suggest, but I was also trying to see if there was a workaround if someone was using the parent option and setting the parent container of the dialog to something other than the document body. So far I haven't found a quick workaround if a user sets the parent to something other than body. Luckily, in my use case, we just let material set the parent container to the document body, but it would be nice if there was a workaround for those who need the parent to be something else.

abouillon avatar Mar 21 '16 12:03 abouillon

I managed to solve my issue today, after hours of digging into code and work arounds. Thought I'd share for anyone else that is struggling with the same problem.

.md-dialog-container { height: 100vh !important; top: 0 !important; position: fixed !important; }

zilions avatar Mar 21 '16 13:03 zilions

@zilions did setting body overflow to initial didnt do the work for you? This seems like a lot of more work

lexyfeito avatar Mar 21 '16 13:03 lexyfeito

@lexyfeito - It did not work in my case unfortunately. Most of my content is absolute positions, so it's probably a different layout to most other sites. The code I posted above is the only way I could get it to work for me.

zilions avatar Mar 21 '16 13:03 zilions

@zilions oh well i am glad you found a fix/workaround at least :)

lexyfeito avatar Mar 21 '16 13:03 lexyfeito

@akashjarad, @abouillon, @zilions: FWIW, you can isolate the workaround by using .md-dialog-is-showing which is appended to the body when a dialog is showing. This seems to fix it for me while still allowing me to use overflow-y: scroll when a dialog is not shown.

body.md-dialog-is-showing {
    overflow: visible !important;
}

You should keep in mind that this and the other fixes mentioned, while fixes our problems right now, could introduce issues going forward. Clearly, Angular is expecting body to be overflow hidden.

rgthree avatar Mar 21 '16 15:03 rgthree

@rgthree you are right and it does work it my case thank you so much for your suggestion.

lexyfeito avatar Mar 21 '16 15:03 lexyfeito

@rgthree hey man this fixed/workaround doesn't seem to work on IE. Does it happen to you to?

lexyfeito avatar Mar 25 '16 12:03 lexyfeito

I'm having this bug too. Thank you @rgthree for the fix.

qmphan avatar Apr 05 '16 22:04 qmphan

@rgthree Sir, you are such a big help! Thanks for the fix!! I have been digging the internet for hours to get this fix.

wengkhing avatar Apr 20 '16 08:04 wengkhing

Just ran into this bug with codes on master branch. It's really wired.

messense avatar May 30 '16 07:05 messense

thanks @rgthree fixed my issue !

bahaaldine avatar Sep 27 '16 07:09 bahaaldine

This was closed but still seems to be an issue on master. Using the suggestions above @rgthree & @zilions helped fix it for me. I'd just like to know if there is going to be an official solution for this? Thanks.

ChrisSoto avatar Nov 28 '16 19:11 ChrisSoto

@rgthree Your solution helped me so much! Can't thank you enough!

palfaro91 avatar Dec 02 '16 00:12 palfaro91