Bug 236561 - REGRESSION?: overflow:hidden on documentElement behaves inconsistently in iOS Safari 15.3.1
Summary: REGRESSION?: overflow:hidden on documentElement behaves inconsistently in iOS...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Scrolling (show other bugs)
Version: Safari 15
Hardware: iPhone / iPad iOS 15
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-13 05:48 PST by ik
Modified: 2022-05-24 13:24 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ik 2022-02-13 05:48:29 PST
When I set `overflow: hidden;` on documentElement and/or scrollingElement, it only prevents scrolling when the scrollTop = 0 and the Safari UI is visible.

If I scroll first, then set `overflow: hidden;`, I can scroll until scrollTop = 0 and Safari UI becomes visible - *then* it locks.

Note: Only tested this on iPad Mini, iOS 15.3.1

I think this is a regression, #153852 covers overflow on body and was marked as fixed:
https://bugs.webkit.org/show_bug.cgi?id=153852

Related tickets (regarding overflow in standalone / home screen apps):
* https://bugs.webkit.org/show_bug.cgi?id=220908
* https://bugs.webkit.org/show_bug.cgi?id=214781
Comment 1 ik 2022-02-13 06:05:36 PST
For people stumbling across this:

My current workaround after a bit of testing and weighing the pros and cons is to detect iOS and force the scrollTop = 0. This is not a solution, however, as it's going to become annoying for users very quickly when the page jumps to the top. The alternative, however, may feel even buggier.

Added bonus: Setting scrollbarGutter will prevent layout shifts when the scrollbar dis-/reappears.

// Lock
if (__isIOS) documentElement.scrollTop = 0;
http://documentElement.style.overflow = 'hidden';
http://documentElement.style.scrollbarGutter = 'stable';

// Unlock
http://documentElement.style.overflow = '';
http://documentElement.style.scrollbarGutter = '';
Comment 2 Radar WebKit Bug Importer 2022-02-13 23:56:04 PST
<rdar://problem/88890931>
Comment 3 Simon Fraser (smfr) 2022-02-14 12:00:25 PST
We allow scrolling when the visual viewport is smaller than the layout viewport (this is necessary to avoid getting locked in when zoomed), but we allow scrolling to the entire document. Ideally we'd only allow panning around in the layout viewport.
Comment 4 Simon Fraser (smfr) 2022-03-03 13:27:47 PST
scrollbarGutter is not implemented in WebKit so I'm not sure what that has any impact.