jenwitteng opened a new pull request, #42561:
URL: https://github.com/apache/superset/pull/42561
### SUMMARY
When `DASHBOARD_VIRTUALIZATION` is enabled, dashboard rows more than a
viewport away are unmounted and replaced with a `<Loading>` spinner (`Row.tsx`
→ `Chart.tsx` `shouldRenderChart`). The client-side **Download as Image /
Download as PDF** path captures the live DOM, so those off-screen charts are
exported as loading spinners instead of the actual charts.
The existing `isCurrentUserBot()` (`window.navigator.webdriver`) bypass only
disables virtualization for **server-side** headless capture (scheduled
reports, thumbnails, the webdriver screenshot endpoints). A real user's browser
has `webdriver === false`, so the client-side `downloadAsImage('.dashboard')` /
`downloadAsPdf('.dashboard')` handlers — used by default when
`ENABLE_DASHBOARD_SCREENSHOT_ENDPOINTS` /
`ENABLE_DASHBOARD_DOWNLOAD_WEBDRIVER_SCREENSHOT` are off — capture unmounted
rows.
This adds a small "force a full render before capturing" contract used only
during export:
- **`src/utils/downloadUtils.ts`** (new): `forceLoadAllCharts()` dispatches
a `superset-force-all-in-view` window event (gated on
`DASHBOARD_VIRTUALIZATION`), polls until the container's `.loading` spinners
clear (60s timeout + a warning toast if it times out), and returns whether
virtualization was active. `restoreVirtualization()` dispatches
`superset-restore-virtualization`.
- **`Row.tsx`**: on force-in-view, disconnect the `IntersectionObserver`s
and render; on restore, re-observe. No change to normal (non-export)
virtualization behavior.
- **`downloadAsPdf` / `downloadAsImage`**: force-load before capture and
restore on **every** exit path — including the ag-grid "still loading" early
return and the error paths — so a failed export never leaves virtualization
disabled for the rest of the session.
Behavior is unchanged when `DASHBOARD_VIRTUALIZATION` is off, and unchanged
for server-side/headless capture.
Context and maintainer discussion:
https://github.com/apache/superset/issues/29719#issuecomment-5116385623
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before:** Exporting a tall dashboard (more than ~1 viewport of charts) as
Image/PDF renders the on-screen charts followed by loading spinners for every
off-screen chart.
**After:** All charts render in the exported image/PDF regardless of scroll
position.
### TESTING INSTRUCTIONS
1. Ensure `DASHBOARD_VIRTUALIZATION` is enabled (default on).
2. Open a dashboard tall enough that some charts are off-screen (e.g. 20+
charts in one tab), and let the visible charts finish loading.
3. Use the dashboard menu → **Download → Export to Image** and **Download →
Export to PDF**.
4. The exported file should contain every chart rendered, not loading
spinners for the off-screen ones.
5. Repeat with `DASHBOARD_VIRTUALIZATION` disabled — behavior should be
unchanged.
Unit tests: `src/utils/downloadUtils.test.ts` (force/restore event dispatch,
timeout warning, flag-off no-op). Existing `downloadAsImage.test.ts` and
`Row.test.tsx` suites pass unchanged.
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #29719
- [ ] Required feature flags:
- [x] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]