PolicyEngine / PolicyEngine/policyengine-model

Post content height to parent when embedded via iframe

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
0
Forks
2
Avg merge
1h 47m
Merged PRs (30d)
1

Description

Problem

When embedded in policyengine-app-v2 at /:countryId/model, the iframe has a fixed height. The parent page's footer sits immediately below the iframe, taking up ~1/3 of the screen instead of appearing only when the user scrolls to the bottom of the content.

Solution

When the ?embed query parameter is present, post the root element's scrollHeight to the parent window via postMessage. Use a ResizeObserver to send updated heights when content changes.

Message format:

{ type: 'policyengine-model-height', height: number }

The parent app (policyengine-app-v2) will listen for this message and resize the iframe accordingly.

Related

  • policyengine-app-v2#697

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the /:countryId/model entry point and inspect how the ?embed query parameter is handled. Verify that the root element's scrollHeight is posted to the parent with the specified message format, and that a ResizeObserver sends updated heights when content changes. Done means the parent app can resize the iframe as its content changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.