Skip to content

Post content height to parent when embedded via iframe #2

@PavelMakarchuk

Description

@PavelMakarchuk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions