fix(block-scroll-strategy): collapsing root node when enabled (#4638)

* Prevents the `html` tag from collapsing when the `BlockScrollStrategy` is enabled.
* Fixes the scroll strategy not being disabled properly in tests.
This commit is contained in:
Kristiyan Kostadinov
2017-05-19 02:04:37 +02:00
committed by Jeremy Elbourn
parent 96549e808b
commit f11d46e75e
2 changed files with 15 additions and 2 deletions
+4 -2
View File
@@ -70,8 +70,10 @@
.cdk-global-scrollblock {
position: fixed;
// Necessary for iOS not to expand past the viewport.
max-width: 100vw;
// Necessary for the content not to lose its width. Note that we're using 100%, instead of
// 100vw, because 100vw includes the width plus the scrollbar, whereas 100% is the width
// that the element had before we made it `fixed`.
width: 100%;
// Note: this will always add a scrollbar to whatever element it is on, which can
// potentially result in double scrollbars. It shouldn't be an issue, because we won't
@@ -23,6 +23,7 @@ describe('BlockScrollStrategy', () => {
}));
afterEach(() => {
strategy.disable();
document.body.removeChild(forceScrollElement);
setScrollPosition(0, 0);
});
@@ -110,6 +111,16 @@ describe('BlockScrollStrategy', () => {
}));
it('should keep the content width', () => {
forceScrollElement.style.width = '100px';
const previousContentWidth = document.documentElement.getBoundingClientRect().width;
strategy.enable();
expect(document.documentElement.getBoundingClientRect().width).toBe(previousContentWidth);
});
/**
* Skips the specified test, if it is being executed on iOS. This is necessary, because
* programmatic scrolling inside the Karma iframe doesn't work on iOS, which renders these