Bug 182710 - WKWebView window.scrollTo() scrolls to wrong position depending on contentInsetAdjustmentBehavior setting
Summary: WKWebView window.scrollTo() scrolls to wrong position depending on contentIns...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Scrolling (show other bugs)
Version: Safari 11
Hardware: iPhone / iPad iOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-12 15:10 PST by Zach Waugh
Modified: 2019-06-16 21:11 PDT (History)
3 users (show)

See Also:


Attachments
Sample project (40.21 KB, application/zip)
2018-02-12 15:10 PST, Zach Waugh
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zach Waugh 2018-02-12 15:10:53 PST
Created attachment 333635 [details]
Sample project

When a WKWebView on iOS 11 uses the default `contentInsetAdjustmentBehavior`, then calls to `window.scrollTo()` don't work correctly. Specifically, `window.scrollTo(0, 0)` will not scroll all the way to the top, leaving content sitting beneath the nav bar. When `contentInsetAdjustmentBehavior = .never` and the content insets are manually set, `window.scrollTo(0, 0)` scrolls to the correct place. In both cases, the actual contentInset is correct, just depends on the adjustment behavior.


I've attached a sample project that reproduces, and is also on GitHub - https://github.com/zachwaugh/wkwebview-bugs/tree/master/ScrollToContentInset
Comment 1 Simon Fraser (smfr) 2018-06-05 13:56:20 PDT
Wenson, is this the thing you fixed?
Comment 2 Wenson Hsieh 2018-06-05 14:01:36 PDT
At a glance, this bug seems more related to how we handle contentInsetAdjustmentBehavior when content insets are specified; the bug I fixed was about how content insets were being conflated with obscuring insets.

It's possible that the other content inset bug has an impact here, though.
Comment 3 Zach Waugh 2018-06-06 09:42:19 PDT
I retested this bug using my test project with some different results now. The original bug I described exists in iOS 11.2 and earlier. It appears to have been fixed in iOS 11.3 and 11.4. In iOS 12 beta 1, it is broken again, but in the opposite way of the original bug, it works correctly for `contentInsetAdjustmentBehavior = .automatic` and fails for `contentInsetAdjustmentBehavior = .never`. I updated my sample project and readme on GitHub (https://github.com/zachwaugh/wkwebview-bugs/tree/master/ScrollToContentInset) with this info.