Skip to content

fix(dashboard): ensure full chart capture in dashboard image exports#34201

Closed
ongdisheng wants to merge 1 commit intoapache:masterfrom
ongdisheng:fix/issue-33904
Closed

fix(dashboard): ensure full chart capture in dashboard image exports#34201
ongdisheng wants to merge 1 commit intoapache:masterfrom
ongdisheng:fix/issue-33904

Conversation

@ongdisheng
Copy link
Contributor

@ongdisheng ongdisheng commented Jul 17, 2025

SUMMARY

Problem

The image export process was based on the visible DOM snapshot, without accounting for overflowed (scrollable) content within the chart.

Solution

To resolve the issue, a new utility function hasScrollableDescendant() was introduced. This function traverses the DOM tree of the target chart element to determine whether it contains any scrollable descendants.

When scrollable content is detected, the chart element is cloned to preserve the original layout. The cloned element is then styled to expand its dimensions based on its scrollHeight and scrollWidth, ensuring the full content area is visible.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before

top-15-languages-spoken-at-home-2025-07-15T04-39-44 126Z

After

top-15-languages-spoken-at-home-2025-07-17T06-09-24 126Z

TESTING INSTRUCTIONS

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

@dosubot dosubot bot added the dashboard:export Related to exporting dashboards label Jul 17, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Functionality Incomplete scrollable element detection ▹ view 🧠 Not in scope
Readability Noisy Style Assignments ▹ view 🧠 Not in standard
Files scanned
File Path Reviewed
superset-frontend/src/utils/downloadAsImage.ts

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Comment on lines +149 to +151
if (element.scrollHeight > element.clientHeight) {
return true;
}

This comment was marked as resolved.

Comment on lines +87 to +95
// Make sure all children don't clip
cloned.querySelectorAll<HTMLElement>('*').forEach(el => {
// eslint-disable-next-line no-param-reassign
el.style.overflow = 'visible';
// eslint-disable-next-line no-param-reassign
el.style.maxHeight = 'none';
// eslint-disable-next-line no-param-reassign
el.style.height = 'auto';
});

This comment was marked as resolved.

@ongdisheng ongdisheng closed this Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard:export Related to exporting dashboards size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant