Skip to content

Commit e27c799

Browse files
committed
fix(block-scroll-strategy): collapsing root node when enabled
Prevents the `html` tag from collapsing when the `BlockScrollStrategy` is enabled.
1 parent e8ab0da commit e27c799

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/lib/core/overlay/_overlay.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
.cdk-global-scrollblock {
7373
position: fixed;
7474

75-
// Necessary for iOS not to expand past the viewport.
76-
max-width: 100vw;
75+
// Necessary for the content not to lose its width.
76+
width: 100%;
7777

7878
// Note: this will always add a scrollbar to whatever element it is on, which can
7979
// potentially result in double scrollbars. It shouldn't be an issue, because we won't

src/lib/core/overlay/scroll/block-scroll-strategy.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ describe('BlockScrollStrategy', () => {
110110
}));
111111

112112

113+
it('should keep the content width', () => {
114+
forceScrollElement.style.width = '100px';
115+
116+
const previousContentWidth = document.documentElement.getBoundingClientRect().width;
117+
118+
strategy.enable();
119+
120+
expect(document.documentElement.getBoundingClientRect().width).toBe(previousContentWidth);
121+
});
122+
113123
/**
114124
* Skips the specified test, if it is being executed on iOS. This is necessary, because
115125
* programmatic scrolling inside the Karma iframe doesn't work on iOS, which renders these

0 commit comments

Comments
 (0)