fix: include portal content in auto-resize#728
Open
federgilad wants to merge 3 commits into
Open
Conversation
Author
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the SDK’s automatic iframe sizing so App.setupSizeChangedNotifications() accounts for out-of-flow “portal” UI (menus/popovers/dialogs) that doesn’t affect the intrinsic html height, and adds an E2E regression to cover portal insert/move/remove, overflow clipping, deduplication, and cleanup.
Changes:
- Extend height measurement to consider the bottom edge of out-of-flow descendants, with overflow-clipping propagation.
- Add a
MutationObservertrigger path (alongsideResizeObserver) and ensure cleanup disconnects observers and cancels pending animation work. - Add a Playwright E2E regression test validating the expected height sequence and cleanup behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/app.ts |
Enhances auto-resize measurement/triggering to include out-of-flow descendants and DOM mutations, with rAF coalescing and cleanup. |
tests/e2e/auto-resize.spec.ts |
Adds an E2E regression that reproduces portal growth/movement/removal and verifies no spurious expansion for clipped scroll content or after cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Fixes #686.
Automatic app resizing previously measured only the intrinsic
htmlheight. Out-of-flow UI rendered through portals, such as menus, dialogs, and popovers, does not contribute to that height, so hosts could keep the iframe too short and clip the portal content.This change:
requestAnimationFramedebounce and size deduplicationBefore
A real Chromium reproduction with 100px of in-flow content and an absolutely positioned portal from 300px to 400px emitted only:
[{"width":1280,"height":100}]The host therefore had no signal that the portal extended to 400px.
After
The Playwright regression exercises initial layout, portal insertion, portal movement, portal removal, clipped scroll content, deduplication, and cleanup. Its height sequence is:
Replacing the content with a 100px
overflow: autocontainer whose child is 1000px tall emits no spurious 1000px resize. Re-inserting the portal after cleanup emits no notification.Validation
npm run buildnpm test: 374 passed, 1 skipped, 0 failedEXAMPLE=say-server npx playwright test tests/e2e/auto-resize.spec.ts --project=chromium --reporter=line: 1 passednpx prettier --check src/app.ts tests/e2e/auto-resize.spec.tsTradeoffs and risk
Measuring portal extent requires inspecting rendered descendant bounds. The work is coalesced to at most one measurement per animation frame, and computed styles are read only for elements with descendants where a clipping boundary could affect their children. Existing width behavior and protocol messages are unchanged.
The mutation observer watches structure, text, and attributes because portal geometry can change without resizing
htmlorbody. Observer records caused by the temporary intrinsic-height style are drained after measurement to avoid feedback loops.No untrusted data is evaluated or transmitted; the change only reads local layout geometry and reports the same width/height notification shape as before.