main ← ux/embed-mode-dynamic-iframe-height
opened 08:00PM - 15 Apr 26 UTC
## Summary
- Add opt-in `dynamicHeight` option for full app embeds that resizes… the iframe based on content
- Add `embedMinHeight` / `embedMaxHeight` options to clamp the dynamic sizing
- Inside the embedded app, a `ResizeObserver` posts `discourse-resize` messages to the parent window
- Scrolling stays enabled inside the iframe — Discourse's virtual DOM only renders ~20 posts at a time and relies on internal scroll position
- Show the new options (commented out) in the admin embedding code snippet
## Usage
```html
<script type="text/javascript">
window.DiscourseEmbed = {
discourseUrl: 'https://forum.example.com/',
topicId: 123,
fullApp: true,
dynamicHeight: true, // opt-in to iframe resizing
embedMinHeight: '400', // optional, pixels
embedMaxHeight: '900', // optional, pixels
embedHeight: '600px', // initial height before first resize
};
</script>
```
## How it works
- **Default (no `dynamicHeight`)**: Full app embed uses fixed height (`embedHeight` or `600px`) with internal scrolling. No change from current behavior.
- **With `dynamicHeight: true`**: The iframe resizes to match content height, clamped by `embedMinHeight` / `embedMaxHeight` if set. Short topics shrink the iframe (no wasted whitespace), long topics grow to max and scroll internally.
## Test plan
- [ ] Full app embed without `dynamicHeight` — verify unchanged behavior (fixed height, scrolling)
- [ ] Full app embed with `dynamicHeight: true` — verify iframe resizes as content loads
- [ ] Verify `embedMinHeight` / `embedMaxHeight` clamp the height correctly
- [ ] Verify standard (non-full-app) embed still resizes as before
- [ ] Open the composer in embed mode — verify height updates propagate
- [ ] Load a long topic — verify virtual DOM post loading works with scrolling
- [ ] Admin > Embedding page shows the new options commented out in the code snippet