Skip to content

fix(embedded): report content height independent of iframe height - #44313

Merged
gabotorresruiz merged 6 commits into
apache:masterfrom
gabotorresruiz:gabotorresruiz/embedded-iframe-content-height
Sep 16, 2026
Merged

gabotorresruiz merged 6 commits into
apache:masterfrom
gabotorresruiz:gabotorresruiz/embedded-iframe-content-height

Conversation

@gabotorresruiz

@gabotorresruiz gabotorresruiz commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

A host sizing an embedded dashboard asks how tall the content is via getScrollSize() and sets the iframe from the answer.
That only terminates if the answer is independent of the iframe height, and it was not: the app fills its frame, so the measurement returned the height the host had just set.

The vertical filter bar compounded it. Its scroll area was sized from calc(100vh - offset), which inside an iframe is the iframe's own height, and the Apply and Clear buttons sat after that area rather than inside it. So the reported height was always frame + constant, and a host applying it grew the iframe on every poll without decay. The same stretch pushed those buttons to the bottom of an oversized frame, far outside the visible area.

Changes:

  • getScrollSize() lifts the fill-the-frame constraints (height and min-height on html, body and #app, plus the filter bar's cap) for one synchronous read, restores them along with the filter list's scroll offset, and reports the viewport before the dashboard has laid out (applying a near-zero height would collapse the embed with no way back, since charts render only when in view).
  • In an embed the filter bar is a bounded flex column, as tall as its content but never taller than the frame, with the filter list as the only scrolling part. Its loading placeholder is no longer viewport-sized either.
  • VersionHistoryColumn no longer renders in embeds. It is sized from 100vh, renders empty for guests, and pinned the document to the frame.
  • The dashboard header was capped with max-width: calc(100vw - filterBarWidth). Viewport units include the scrollbar gutter, so with classic scrollbars a header whose min-content width exceeded the content column ran past the visible edge and the dashboard scrolled horizontally by the scrollbar's width. The grid track already knows its own width, and min-width: 0 stops the header's min-content width from propping the column open, so at narrow widths charts can get a slightly narrower track than before.

The embed gating uses isEmbedded(), which is true for any iframe, not only the SDK, so a dashboard iframed by a logged-in user gets the same layout.

Known limitation: with a frame larger than the content the buttons are not pinned to the visible area, because a guest cannot know which part of itself the host has on screen. Their position is now bounded by the content height instead of the iframe height, so it no longer scales with the frame.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Measured against a local Superset with the embedded SDK test host, 1280x800 window, Chromium with classic scrollbars. "Sales Dashboard" is the example with a 7-filter vertical bar; "World Bank's Data" has no filter bar.

before after
getScrollSize().height at 800px / 2400px frames (Sales) 983 / 2418 983 / 983
Same, World Bank's Data 1665 / 2400 1665 / 1665
Host resize loop (height + 40 per tick), per-tick delta +58 forever (Sales), +40 forever (World Bank) 0 from the first tick
Apply filters button in a 4000px frame (Sales) 3908px down 843px down, right under the last filter
Horizontal overflow, dashboard page with the filter bar open, 900px wide 15px (scrolls by the scrollbar width) 0

Host resize loop, 10 ticks. Before, every poll returns the height the host just set plus a constant, so the iframe grows without bound. After, the answer no longer depends on the frame and the loop settles on its first tick.

resize-loop

Host oversized the frame to 2000px. Before, the filter list was sized from 100vh (the frame itself, inside an iframe) and Apply / Clear came after it, 1908px down. After, the bar is bounded to its content, the buttons sit under the last filter at 843px, and only the list scrolls.

oversized-frame-2000px

Dashboard page at 900px with the filter bar open, scrolled fully right. Before, the header was capped at calc(100vw - filterBarWidth), which includes the scrollbar gutter, so the page scrolled horizontally by the scrollbar's width. After, the header is bounded by its grid track and there is nothing to scroll.

header-horizontal-overflow-900px

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@netlify

netlify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 46a8fa9
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aaab1ce197a8e0008f62c81
😎 Deploy Preview https://deploy-preview-44313--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@gabotorresruiz
gabotorresruiz force-pushed the gabotorresruiz/embedded-iframe-content-height branch from dce6f0e to def4b4e Compare September 15, 2026 22:02
@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.87755% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.28%. Comparing base (bd76e09) to head (1cae80c).

Files with missing lines Patch % Lines
...rd/components/nativeFilters/FilterBar/Vertical.tsx 82.35% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #44313   +/-   ##
=======================================
  Coverage   80.28%   80.28%           
=======================================
  Files        2928     2929    +1     
  Lines      174122   174153   +31     
  Branches    40404    40416   +12     
=======================================
+ Hits       139790   139826   +36     
+ Misses      31675    31670    -5     
  Partials     2657     2657           
Flag Coverage Δ
javascript 75.69% <93.87%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gabotorresruiz
gabotorresruiz marked this pull request as ready for review September 16, 2026 15:12
@gabotorresruiz
gabotorresruiz requested review from aminghadersohi, rebenitez1802 and rusackas and removed request for rusackas September 16, 2026 15:12

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve — the core fix is sound: getScrollSize() now measures content independent of the iframe height, the restore/finally path is correct, the #app .dashboard / .filter-bar-bounded / .filter-bar-scroll selectors match the real DOM and survive the prod build (they key off classNames/ids, not stripped data-test), and there's no security-boundary change for the embedded-guest principal. Only low-severity cleanups, all optional.

🟢 Low — Dead currentFilterBarWidth state + no-op setState during render
In DashboardBuilder.tsx, removing headerFilterBarWidth deleted the only reader of currentFilterBarWidth (declared :599). It's now referenced solely to guard its own setter at :806-807, and renderChild calls setCurrentFilterBarWidth while ResizableSidebar invokes children(width) during render (ResizableSidebar/index.tsx:82) — so every vertical filter-bar width change fires a wasted extra render whose value nothing consumes. Fix: delete the useState at :599 and the if (…) setCurrentFilterBarWidth(…) guard at :806-807.

🟢 Low — Three header tests now assert an identical rule
DashboardBuilder.test.tsx:525/555/581 set up distinct filter-bar states (open 320px / collapsed / hidden) but all three assert the same max-width: 100% + min-width: 0, since StyledHeader no longer branches on filter-bar width. They still guard the "header never depends on filter-bar width" invariant per state (not vacuous), but the three scenario names overstate what's covered. Optional: fold into one parameterized case.

🟢 Low — New embed-only branches have no unit coverage
VersionHistoryColumn suppression (:1008, !isEmbedded()) and the FiltersPanel border-right (:118, isEmbedded()) aren't exercised in jsdom — isEmbedded() is false by default and no test mocks it true. The real regression that matters (VersionHistory's 100vh re-pinning the document height and reviving the resize loop) is already caught by the new embedded-iframe-sizing.spec.ts, so this is minor — a small isEmbedded-mocked render test would lock the conditional cheaply.

🟢 Low — Helper extraction left its companions triplicated
The new playwright/helpers/embeddedAppServer.ts removed the copy-pasted static server, but createAdminContext, the SUPERSET_DOMAIN/SUPERSET_BASE_URL derivation, and the test.skip(!existsSync(SDK_BUNDLE_PATH), …) guard remain byte-for-byte across all three embedded specs (two of the three copies predate this PR). Optional: move these natural companions into the same helper so admin-auth/URL changes stay single-sourced.

@bito-code-review

bito-code-review Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #d3e30c

Actionable Suggestions - 0
Additional Suggestions - 5
  • superset-frontend/playwright/helpers/embeddedAppServer.ts - 1
    • Uncaught server errors · Line 49-73
      The request handler calls `readFileSync` with no try/catch, and the temporary `server.once('error', reject)` is removed at line 83 after `listen()` succeeds. A synchronous throw in the listener (e.g. EMFILE under many Playwright workers, or a file removed between `existsSync` and `readFileSync`) becomes an uncaughtException and crashes the worker; a later server 'error' with zero listeners also throws. Consider a try/catch returning 500 and a persistent `server.on('error', ...)`.
  • superset-frontend/playwright/tests/embedded/embedded-iframe-sizing.spec.ts - 1
    • networkidle hang risk · Line 191-191
      `waitForLoadState('networkidle')` is discouraged by Playwright and can hang when a page keeps persistent connections (e.g. websockets/polling in an embedded dashboard). The following `settled()` poll on `.filter-bar-scroll` already waits for the list to stabilize, so this call is redundant and adds flake/hang risk. Consider removing it or polling a specific selector.
  • superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx - 1
    • Redundant test assertions · Line 549-550
      These three tests (lines 525, 555, 581) now assert identical static CSS (`max-width: 100%`, `min-width: 0`) regardless of the filter-bar state named in each test. Since the rule no longer depends on sidebar width, the scenarios aren't actually differentiated. Consider consolidating into one test or asserting state-specific behavior so the names match the assertions.
  • superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx - 1
    • Dead state after prop removal · Line 851-853
      Deleting `headerFilterBarWidth` removed the only reader of the `currentFilterBarWidth` state (declared ~599, written in `renderChild` ~806). The state is now write-only and triggers a redundant re-render on every filter-bar width change. Consider removing the state and its setter.
  • superset-frontend/playwright/tests/embedded/embedded-dashboard.spec.ts - 1
    • Stale comment after refactor · Line 48-48
      This comment block describes the static file server that was extracted to `helpers/embeddedAppServer.ts`, but it was left behind and now sits directly above `createAdminContext`, which it doesn't describe. Per AGENTS.md, comments should remain accurate. Remove the orphaned block.
Review Details
  • Files reviewed - 9 · Commit Range: 3055e44..46a8fa9
    • superset-frontend/playwright/helpers/embeddedAppServer.ts
    • superset-frontend/playwright/tests/embedded/embedded-dashboard.spec.ts
    • superset-frontend/playwright/tests/embedded/embedded-iframe-sizing.spec.ts
    • superset-frontend/playwright/tests/embedded/pivot-collapse-state.spec.ts
    • superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx
    • superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
    • superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Vertical.tsx
    • superset-frontend/src/embedded/api.test.ts
    • superset-frontend/src/embedded/api.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@gabotorresruiz

Copy link
Copy Markdown
Contributor Author

Thanks @rebenitez1802 for the review. Addressed in 1dcf1e5: dropped the dead currentFilterBarWidth state and its render-time setter, added isEmbedded-mocked tests for the version-history suppression and the panel separator, and moved createAdminContext, the origin derivation and the SDK-bundle skip into embeddedAppServer.ts so all three embedded specs share them. Kept the three header tests as they are: each pins the invariant for a distinct filter-bar state, and the names read better than one parameterized case.

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving after the new commit — the core fix and tests look solid. Two non-blocking robustness nits inline that may be worth a follow-up; neither blocks landing.

Comment thread superset-frontend/src/embedded/api.tsx Resolved
Comment thread superset-frontend/src/embedded/api.tsx Resolved
gabotorresruiz and others added 5 commits September 16, 2026 15:59
A host embedding a dashboard cannot know how tall the content is, so the
documented pattern asks via getScrollSize() and sizes the iframe from the
answer. That only terminates if the answer does not depend on the iframe
height, and it did.

The app fills its frame by design, so measuring it returned the height the
host had just set. On top of that the vertical filter bar sized its scroll
area from 100vh, which inside an iframe is the iframe's own height, and put
the Apply and Clear buttons below that area. The reported height was
therefore always the frame plus a constant, and a host applying it grew the
iframe on every poll, without bound.

getScrollSize() now lifts the fill the frame constraint for a single
synchronous read, so it describes the content. Before the dashboard lays
out it reports the viewport instead, because a host applying a near zero
height would collapse the embed and charts only render once in view, so it
could not recover.

In an embed the filter bar becomes a bounded flex column, as tall as its
content but never taller than the frame. The filter list is the only part
that scrolls, so the buttons stay inside the panel instead of following the
frame down. The column separator moves to the panel behind the bar, which
spans the full height either way, and the 108px reservation that existed to
clear absolutely positioned buttons is dropped since they no longer float
over the list.

VersionHistoryColumn no longer renders in embeds. It is sized from 100vh,
is empty for guests, and pinned the document height to the frame.

Separately, the dashboard header was capped with
max-width: calc(100vw - filterBarWidth). Viewport units include the
scrollbar gutter, so with classic scrollbars the header ran past the visible
edge and every dashboard with the filter bar open scrolled horizontally by
the width of the scrollbar. The grid track already knows its own width.
The three header width tests asserted the viewport based cap that this
branch replaces. Update them to the new invariant, keeping their open,
collapsed and hidden filter bar setups so the scenarios stay covered.
… actions

The last sizing test measured the bottom of the dashboard container, which
fills its frame by design on both master and this branch, so it failed in CI
for every frame taller than the content. What the fix actually pins is where
the filter bar's Apply and Clear buttons land, and the world_health example
has no filter bar to observe that on.

Build the fixture the spec needs instead: one chart plus twelve vertical
filters, so the bar overflows the window. Assert that the Apply button stays
put between a 2400px and a 4000px frame and sits inside the reported content
height, which fails on master with the buttons at the bottom of the frame.
The filter controls keep growing as their options arrive, so wait for the
guest's network and the list's height to settle before measuring.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ded spec setup

Removing the header's viewport cap left currentFilterBarWidth with no reader.
It only guarded its own setter, which ran during render through the
sidebar's render prop, so every filter bar resize paid for an extra render
that nothing consumed. Delete both.

Lock the two embed-only branches in DashboardBuilder with unit tests that
mock isEmbedded: the version history column stays out of an embed, and the
filters panel draws the column separator there.

The three embedded Playwright specs each carried the same admin context
factory, Superset origin derivation and SDK bundle skip guard. Move them next
to the shared app server helper so a change to admin auth or the base URL is
made once.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Each filter control renders a loading row until its values arrive, then
swaps in the real control at a different height. On a loaded CI runner the
last few values can land seconds apart, so a measurement taken between two
of them differed from one taken after. Wait until all controls have loaded
and the list has held its size for two seconds before reading anything.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@gabotorresruiz
gabotorresruiz force-pushed the gabotorresruiz/embedded-iframe-content-height branch from 16e6b77 to 2fdc581 Compare September 16, 2026 18:59
…class names

getScrollSize() treated a non-zero dashboard height as "laid out", but the
header and tabs give the container height before the grid mounts. A host
polling in that window would apply the chrome-only height, shrink the frame,
and charts that render only in view would never appear. Gate on the store
having hydrated and the grid being in the DOM instead; the grid's rows take
their heights from the layout, so once it is there the measurement is
complete even while charts are still loading.

The class names the measurement keys off were string literals in the filter
bar, the API and the unit test fixture, so a rename in the component would
have passed the unit test and broken production. Move them to one module
that all three import.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@gabotorresruiz
gabotorresruiz merged commit 637e19f into apache:master Sep 16, 2026
83 checks passed
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

villebro pushed a commit that referenced this pull request Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants