Skip to content

Commit 26928b8

Browse files
Fix autoResize reporting viewport height when content is taller (#525)
fit-content clamps to the containing block's available size. For <html>, that's the iframe viewport, so when content exceeds the viewport height the SDK reported the viewport height instead of the true content height, causing internal scrolling instead of iframe growth. max-content has no available-space constraint and correctly reports the intrinsic content height in both directions (shrink and grow). Width stays fit-content to preserve responsive wrapping.
1 parent 134c71c commit 26928b8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/app.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,13 +1119,14 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> {
11191119
scheduled = false;
11201120
const html = document.documentElement;
11211121

1122-
// Measure actual content size by temporarily setting html to fit-content.
1123-
// This shrinks html to fit body (including body margins), giving us the
1124-
// true minimum size needed by the content.
1122+
// Measure actual content size by temporarily overriding html sizing.
1123+
// Width uses fit-content so content wraps at the host-provided width.
1124+
// Height uses max-content because fit-content would clamp to the viewport
1125+
// height when content is taller than the iframe, causing internal scrolling.
11251126
const originalWidth = html.style.width;
11261127
const originalHeight = html.style.height;
11271128
html.style.width = "fit-content";
1128-
html.style.height = "fit-content";
1129+
html.style.height = "max-content";
11291130
const rect = html.getBoundingClientRect();
11301131
html.style.width = originalWidth;
11311132
html.style.height = originalHeight;

0 commit comments

Comments
 (0)