Re: [csswg-drafts] [css-overscroll] the target of overscroll-behavior should be scrolling box instead of scroll container? (#6523)

I think it's helpful if scrolling on an `overflow: auto` element with no scroll range doesn't hand off to outer elements. The major use case is to prevent background scrolling when a modal dialog is open.

Many people are looking for a way to prevent background scrolling when a modal dialog is open. [Some people use `body { overflow: hidden; }`](https://www.folkstalk.com/2022/09/how-to-stop-background-scrolling-when-popup-is-open-with-code-examples.html) but this way has some problems:

1. Needs JavaScript to know the timing to specify `overflow: hidden` to the `body` element.
2. Scrollbar gutter disappears and the reflow happens on the content of the `body` element.

If scrolling on an element with no scroll range doesn't hand off, we can just write as `dialog:modal { overscroll-behavior: contain; }`. [This way](https://jsfiddle.net/6yv230xp/) works as expected on Chrome canary 110 but doesn't work on Firefox nightly 109.

[^1]: e.g. 

-- 
GitHub Notification of comment by nanto
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6523#issuecomment-1331631761 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 30 November 2022 04:31:55 UTC