Skip to content

Commit e9277ea

Browse files
committed
Fix(web): Simplify scroll blocking used by Modal and OffCanvas to CSS-only solution #DS-1124
1 parent bfa569f commit e9277ea

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

packages/web/src/js/utils/ScrollControl.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ class ScrollControl {
2727
const clientOffset = this.element.tagName === 'BODY' ? window.innerWidth : this.element.offsetWidth;
2828
// Browser scrollbar width, may be 0 on some devices, but solves offset when is not 0.
2929
const scrollBarWidth = clientOffset - this.element.clientWidth;
30-
// Save Y offset for later purpose
31-
this.offsetY = window.scrollY;
3230
// Fixing page offset causing scrollbar on some devices
3331
this.element.style.paddingRight = `${scrollBarWidth}px`;
34-
// Fixing position
35-
this.element.style.top = `-${this.offsetY}px`;
3632
// Add body class
3733
this.element.classList.add(SCROLLING_DISABLED_CLASSNAME);
3834
}
@@ -44,11 +40,8 @@ class ScrollControl {
4440
executeAfterTransition(this.target, () => {
4541
// Reset style values
4642
this.element.style.paddingRight = '';
47-
this.element.style.top = '';
4843
// Remove body class
4944
this.element.classList.remove(SCROLLING_DISABLED_CLASSNAME);
50-
// Scroll after close to saved Y offset position
51-
window.scrollTo(0, this.offsetY);
5245
});
5346
}
5447
}

packages/web/src/scss/components/Modal/_Modal.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
visibility: hidden; // 1.
2323
opacity: 0; // 1.
2424
pointer-events: none; // 1.
25+
overscroll-behavior: contain;
2526

2627
// 2.
2728
&::backdrop {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
.is-scrolling-disabled {
2-
position: fixed;
3-
width: 100%;
4-
overflow-y: hidden;
2+
overflow: hidden;
53
}

0 commit comments

Comments
 (0)