diff --git a/docs/Reference.md b/docs/Reference.md index 8dbd492..9f05793 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -446,7 +446,7 @@ With the [new WebKit](Reference.md#usewebkit) implementation, we have three new ### `scrollEnabled` -Boolean value that determines whether scrolling is enabled in the `WebView`. The default value is `true`. +Boolean value that determines whether scrolling is enabled in the `WebView`. The default value is `true`. Setting this to `false` will prevent the webview from moving the document body when the keyboard appears over an input. | Type | Required | Platform | | ---- | -------- | -------- | diff --git a/ios/RNCWKWebView.m b/ios/RNCWKWebView.m index c60ffb3..c5518bd 100644 --- a/ios/RNCWKWebView.m +++ b/ios/RNCWKWebView.m @@ -341,6 +341,19 @@ static NSURLCredential* clientAuthenticationCredential; { _scrollEnabled = scrollEnabled; _webView.scrollView.scrollEnabled = scrollEnabled; + + // Override the scrollView delegate to prevent scrolling. + if (!scrollEnabled) { + _webView.scrollView.delegate = self; + } else { + _webView.scrollView.delegate = _webView; + } +} + +- (void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + // Don't allow scrolling the scrollView. + scrollView.bounds = _webView.bounds; } - (void)setShowsHorizontalScrollIndicator:(BOOL)showsHorizontalScrollIndicator