Report content height for iframe auto-sizing across all widgets#49
Merged
Conversation
function-plotter and image-comparison-table now post { type: 'resize', height } to window.parent via a ResizeObserver, matching what pennsic-planner and japanese-verb-tower already do, so a host can auto-size the iframe to the widget's content. image-comparison-table reports its natural (untransformed) content height — scrollHeight is unaffected by the fit-scale transform — so its existing fit-to-viewport scaling remains the fallback for hosts that pin a fixed height instead.
Standardise the message type on 'resize' (verb-tower previously emitted 'widget-size') so a host needs a single listener for every widget; match the right iframe with event.source. Documented the host-side listener in the function-plotter and image-comparison READMEs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Completes the embedding work: every widget now tells its host how tall it wants to be, so a host can auto-size the iframe instead of guessing a fixed height.
What changed
{ type: "resize", height }towindow.parentvia aResizeObserver— the same thing pennsic-planner and japanese-verb-tower already did. These were the two that lacked it.resize. verb-tower previously emittedwidget-size; now all four speak the same protocol, so a host needs a single listener and matches the right iframe withevent.source.image-comparison-table + fit-scale
This widget scales its grid to fit a fixed viewport. It now reports its natural (untransformed) content height (
scrollHeightis unaffected by the fit-scale transform), so:Reporting natural height (guarded against no-op posts + debounced) keeps the two mechanisms from fighting: the height is transform-invariant, so there's no resize feedback loop.
Verification
scripts/validate-widgets.mjspasses locally (4/4); theresizeeffect is a faithful copy of the already-deployed pennsic/verb-tower pattern. The PR'scheck-widgetsCI builds every changed widget (npm run build), which is the real type/build gate.🤖 Generated with Claude Code