Permalink
Browse files

Webview: Fix broken fullscreen modals due to zero body height.

Summary:
Supersedes PR #8536
Fixes #5211

JavaScript plugins such as Fotorama are broken when attempting use its fullscreen feature.

If there's an absolute HTML element with 100% height under <body>, its height is 0 when rendered in the Android WebView.

This commit fixes it.
Closes #8830

Reviewed By: bestander

Differential Revision: D3632821

Pulled By: jamesgpearce

fbshipit-source-id: c185bcd30d1d214a357d0d8552d61d0ddfa5e6c6
  • Loading branch information...
1 parent aa32fd6 commit 1bb1385c7d199a473f76cdec357de2ab4d1d61b6 @danielbraun danielbraun committed with Facebook Github Bot 7 Jul 27, 2016
@@ -18,6 +18,7 @@
import android.graphics.Bitmap;
import android.os.Build;
import android.text.TextUtils;
+import android.view.ViewGroup.LayoutParams;
import android.webkit.GeolocationPermissions;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@@ -267,6 +268,11 @@ public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermiss
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
+ // Fixes broken full-screen modals/galleries due to body height being 0.
+ webView.setLayoutParams(
+ new LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.MATCH_PARENT));
+
if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}

0 comments on commit 1bb1385

Please sign in to comment.