Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Opening a modal with scrollbar-gutter: stable shifts the page content and shows white (non grey-overlayed) gutters #40736

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions js/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,26 @@ class Modal extends BaseComponent {

this._isShown = true
this._isTransitioning = true

// Check if any parent or ancestor has scrollbar-gutter: stable both-edges

let parentElement = this._element.parentElement;
let hasScrollbarGutter = false;

while (parentElement) {
const scrollbarGutter = window.getComputedStyle(parentElement).getPropertyValue('scrollbar-gutter');
if (scrollbarGutter.includes('stable')) {
hasScrollbarGutter = true;
break;
}
parentElement = parentElement.parentElement;
}

// Only hide the scrollbar if no scrollbar-gutter: stable both-edges is found

if (!hasScrollbarGutter) {
this._scrollBar.hide();
}

this._scrollBar.hide()

Expand Down Expand Up @@ -301,11 +321,13 @@ class Modal extends BaseComponent {
if (isBodyOverflowing && !isModalOverflowing) {
const property = isRTL() ? 'paddingLeft' : 'paddingRight'
this._element.style[property] = `${scrollbarWidth}px`
console.log("AAAA");
}

if (!isBodyOverflowing && isModalOverflowing) {
const property = isRTL() ? 'paddingRight' : 'paddingLeft'
this._element.style[property] = `${scrollbarWidth}px`
console.log("AAAA");
}
}

Expand Down