Skip to content

Conversation

@dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Jan 6, 2026

What?

Ensure the editor HTML expands to fill the viewport height.

Why?

The editor background is clipped if the root element does not expand to fill the entire height.

How?

Set explicit layoutParams with MATCH_PARENT on GutenbergView when used inside Compose's AndroidView. This fixes CSS viewport units (vh, vw, dvh) calculating as zero.

When a WebView is embedded in AndroidView without explicit layoutParams, the WebView's initial size is calculated as zero during the first composition pass. This causes CSS viewport units to resolve to 0px, even though JavaScript APIs like window.innerHeight return correct values.

Setting MATCH_PARENT layoutParams ensures the WebView knows its intended size constraints before loading content, allowing CSS viewport calculations to work correctly.

This is a known issue with WebView in Jetpack Compose:

Testing Instructions

This is particularly notable if a theme's styles are applied to the editor via #260.

Example background clipping

gbk-android-body-background

To verify the fix manually, rely upon the Chrome DevTools to inspect the element height:

  1. Open the demo app editor on Android.
  2. Inspect the WebView via the Chrome DevTools.
  3. Verify the html element does not have a height of 0, but fills the entire viewport.

Accessibility Testing Instructions

N/A, no navigation changes.

Screenshots or screencast

Before After
before after

Ensure the editor HTML expands to fill the viewport height.

Set explicit `layoutParams` with MATCH_PARENT on `GutenbergView` when
used inside Compose's `AndroidView`. This fixes CSS viewport units
(`vh`, `vw`, `dvh`) calculating as zero.

When a WebView is embedded in `AndroidView` without explicit
`layoutParams`, the WebView's initial size is calculated as zero
during the first composition pass. This causes CSS viewport units
to resolve to 0px, even though JavaScript APIs like
`window.innerHeight` return correct values.

Setting `MATCH_PARENT` `layoutParams` ensures the WebView knows its
intended size constraints before loading content, allowing CSS
viewport calculations to work correctly.

This is a known issue with WebView in Jetpack Compose:
- https://issuetracker.google.com/issues/238245846
- google/accompanist#1224
@dcalhoun dcalhoun added the [Type] Bug An existing feature does not function as intended label Jan 6, 2026
@dcalhoun dcalhoun marked this pull request as ready for review January 6, 2026 19:28
@dcalhoun dcalhoun requested a review from nbradbury January 6, 2026 19:28
@dcalhoun dcalhoun enabled auto-merge (squash) January 6, 2026 19:28
@nbradbury nbradbury self-assigned this Jan 6, 2026
Copy link
Contributor

@nbradbury nbradbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! :shipit:

@dcalhoun dcalhoun merged commit 0f003d0 into trunk Jan 6, 2026
12 checks passed
@dcalhoun dcalhoun deleted the fix/android-demo-editor-fills-viewport branch January 6, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants