Uh oh!
There was an error while loading. Please reload this page.
fix(app): autoResize collapses height:100% layouts; expose autoResize in useApp - #619
fix(app): autoResize collapses height:100% layouts; expose autoResize in useApp#619ochafik wants to merge 1 commit into
Conversation
… in useApp
setupSizeChangedNotifications measured height by transiently forcing
html.style.height = "max-content". During that reflow, descendants with
height:100% resolve to auto (parent has no definite size), so apps that
set html,body{height:100%} with a viewport-filling child reported a
spinner-sized height — and never recovered once the iframe shrank.
Measure body.scrollHeight + body margins instead. This still grows on
overflow (#525) and shrinks for default-styled bodies (#57), without
overriding author styles. Apps that explicitly set body{height:100%} no
longer shrink below the host's initial size, which is the semantically
correct behavior for a viewport-filling layout.
Also expose `autoResize` in UseAppOptions so React apps can opt out
without dropping the hook.
Addresses #143, #189, #502.📖 Docs Preview Deployed
Includes drafts and future-dated posts. All pages served with |
@modelcontextprotocol/ext-apps@modelcontextprotocol/server-basic-preact@modelcontextprotocol/server-basic-react@modelcontextprotocol/server-basic-solid@modelcontextprotocol/server-basic-svelte@modelcontextprotocol/server-basic-vanillajs@modelcontextprotocol/server-basic-vue@modelcontextprotocol/server-budget-allocator@modelcontextprotocol/server-cohort-heatmap@modelcontextprotocol/server-customer-segmentation@modelcontextprotocol/server-debug@modelcontextprotocol/server-map@modelcontextprotocol/server-pdf@modelcontextprotocol/server-scenario-modeler@modelcontextprotocol/server-shadertoy@modelcontextprotocol/server-sheet-music@modelcontextprotocol/server-system-monitor@modelcontextprotocol/server-threejs@modelcontextprotocol/server-transcript@modelcontextprotocol/server-video-resource@modelcontextprotocol/server-wiki-explorercommit: |
ochafik
commented
Apr 21, 2026
Closing — the safe half of this (exposing Tracking the underlying #143 bug separately; in the meantime the workaround is |
ochafik
commented
Apr 21, 2026
Reopening as draft. The bug is real (#143 has two reporters and a root-cause from @kashtian pointing at exactly this
|
ochafik
commented
Apr 21, 2026
@mel-anthropic could you take a look? This touches the height path you deliberately kept as Context: #143's comment from @kashtian root-causes the
Would be great to validate on mobile alongside the e2e screenshot pass before this comes out of draft. |
Problem
setupSizeChangedNotificationsmeasured content height by transiently settinghtml.style.height = "max-content". During that synchronous reflow, any descendant withheight: 100%resolves toauto(the parent now has indefinite/intrinsic size). Apps that use the commonhtml, body { height: 100% }reset with a viewport-filling child therefore reported a spinner-sized height on first measure — and once the host shrank the iframe, the layout never recovered (the100%child now fills a tiny iframe, soResizeObserversees no further change).Fix
Measure
document.body.scrollHeight+ vertical body margins instead of overriding<html>styles.max-contentoverride)body.scrollHeight)html,body{height:100%}+100%childbody{height:100%}+ short contentThe last row is the only behavior change for previously-working apps, and it's arguably the right behavior: an app that declares
body { height: 100% }is asking to fill the viewport, not shrink-wrap. Apps that need explicit control should pass{ autoResize: false }.Also
autoResizeinUseAppOptionsso React apps can opt out without abandoning theuseApp()hook (autoResize: true default causes layout bugs — need height management guidance #502 proposal 2).Addresses
useApp({ autoResize: false }))