question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modal opening moves body up

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Opening a modal does not moves body up.

What is the current behavior?

A negative top is applied to the body, causing elements to go up. This comes back to normal when closing the modal

What are the steps to reproduce?

  • Create an element with position: fixed
  • Scroll down your page so that you are not at the top
  • Open the modal

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

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

  • Angular core : 4.3.1
  • Angular material : 2.0.0-beta.8
  • TypeScript : 2.3.4

Tested on chrome 61 Win / Mac / Linux

Is there anything else we should know?

❤️

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
speigecommented, Aug 7, 2018

+1

I fixed it like this

.cdk-global-scrollblock {
	position: initial;
	width: initial;
	overflow: hidden;
}
3reactions
rahul-y-dudhanecommented, Apr 26, 2019

I faced same problem. Following solution work for me,

.cdk-global-scrollblock{
      position: static !important;
      width: initial !important;
      overflow-y: inherit !important;
    }

Put it into your global css or in dialog components loacl css (you have to enable view encapsulation in case of local)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap modal: background jumps to top on toggle
When the modal opens a modal-open class is set to the <body> tag. This class sets overflow: hidden; to the body. Add this...
Read more >
Modal - Bootstrap
The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds . modal-open to the <body> to...
Read more >
How to prevent Body from scrolling when a modal is opened ...
Given an HTML document with a modal, the task is to prevent the body element from scrolling whenever the modal is in an...
Read more >
Bootstrap Modal Position - Visual LightBox
In the event that the height of a modal switch though it is open up, you can command $(' #myModal'). data(' bs.modal'). handleUpdate()...
Read more >
Prevent Page Scrolling When a Modal is Open | CSS-Tricks
You open a modal, scroll through it, close it, and wind up somewhere ... the body still scrolls when a modal is open...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found