Repository navigation
fix(embedded): report content height independent of iframe height - #44313
gabotorresruiz merged 6 commits into
Conversation
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
dce6f0e to
def4b4e
Compare
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rebenitez1802
left a comment
There was a problem hiding this comment.
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.
Code Review Agent Run #d3e30cActionable Suggestions - 0Additional Suggestions - 5
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Thanks @rebenitez1802 for the review. Addressed in 1dcf1e5: dropped the dead |
rebenitez1802
left a comment
There was a problem hiding this comment.
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.
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]>
16e6b77 to
2fdc581
Compare
…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]>
|
Bito Automatic Review Skipped – PR Already Merged |
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 alwaysframe + 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 (heightandmin-heightonhtml,bodyand#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).VersionHistoryColumnno longer renders in embeds. It is sized from100vh, renders empty for guests, and pinned the document to the frame.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, andmin-width: 0stops 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.
getScrollSize().heightat 800px / 2400px frames (Sales)height + 40per tick), per-tick delta+58forever (Sales),+40forever (World Bank)0from the first tickHost 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.
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.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.ADDITIONAL INFORMATION