Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ export const useExploreAdditionalActionsMenu = (
'.panel-body .chart-container',
slice?.slice_name ?? t('New chart'),
true,
theme,
)(e.domEvent);
setIsDropdownVisible(false);
dispatch(
Expand Down
18 changes: 18 additions & 0 deletions superset-frontend/src/utils/downloadAsImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,29 @@ const processCloneForVisibility = (clone: HTMLElement) => {
});
};

const preserveCanvasContent = (original: Element, clone: Element) => {
const originalCanvases = original.querySelectorAll('canvas');
const clonedCanvases = clone.querySelectorAll('canvas');

originalCanvases.forEach((originalCanvas, i) => {
if (originalCanvases[i] && clonedCanvases[i]) {
const clonedCanvas = clonedCanvases[i] as HTMLCanvasElement;
const ctx = clonedCanvas.getContext('2d');
if (ctx) {
clonedCanvas.width = originalCanvas.width;
clonedCanvas.height = originalCanvas.height;
ctx.drawImage(originalCanvas, 0, 0);
}
}
});
};

const createEnhancedClone = (
originalElement: Element,
): { clone: HTMLElement; cleanup: () => void } => {
const clone = originalElement.cloneNode(true) as HTMLElement;
copyAllComputedStyles(originalElement, clone);
preserveCanvasContent(originalElement, clone);

const tempContainer = document.createElement('div');
tempContainer.style.cssText = `
Expand Down
Loading