Open Bug 1837436 Opened 1 year ago Updated 2 months ago

CSS overscroll-behavior does not work when scroll container has no overflow

Categories

(Core :: Layout: Scrolling and Overflow, defect, P3)

Firefox 116
defect

Tracking

()

UNCONFIRMED

People

(Reporter: sime.vidas, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/116.0

Steps to reproduce:

  1. Open https://codepen.io/rctneil/pen/rJYONj?editors=0100
  2. try to scroll the page

Actual results:

The page scrolled.

Expected results:

The page should not have scrolled.

The fullscreen overlay has the following styles:

overflow: hidden;
overscroll-behavior: contain;

This means that it’s a scroll container and that scroll chaining is disabled. Therefore, the page behind the overlay should not scroll.

The corresponding Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=813094

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Scrolling and Overflow' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout: Scrolling and Overflow
Product: Firefox → Core
Severity: -- → S3
Priority: -- → P3

Thanks for the detailed bug report! Marking as S3/P3 since my testing on chrome canary seems to indicate the issue still exists there.

Use JavaScript to prevent background scrolling:

javascript

function showOverlay() {
document.getElementById('overlay').style.display = 'block';
document.body.style.overflow = 'hidden'; // Prevent background scrolling
}

function hideOverlay() {
document.getElementById('overlay').style.display = 'none';
document.body.style.overflow = 'auto'; // Restore background scrolling
}

This serves as a workaround until the browser bug is fixed. For more tips on handling scrollbars in CSS, check out my blog post: (https://forfrontend.com/how-to-show-scrollbar-on-hover-in-css/).

You need to log in before you can comment on or make changes to this bug.