diff --git a/public/app/features/dashboard-scene/sharing/panel-share/SharePanelPreview.tsx b/public/app/features/dashboard-scene/sharing/panel-share/SharePanelPreview.tsx index 94345914fdb..03654f1f0ad 100644 --- a/public/app/features/dashboard-scene/sharing/panel-share/SharePanelPreview.tsx +++ b/public/app/features/dashboard-scene/sharing/panel-share/SharePanelPreview.tsx @@ -50,8 +50,13 @@ export function SharePanelPreview({ title, imageUrl, buildUrl, disabled, theme } buildUrl({ width: watch('width'), height: watch('height'), scale: watch('scaleFactor') }); }, [buildUrl, watch]); - const [{ loading, value: image, error }, renderImage] = useAsyncFn(async () => { - const { width, height, scaleFactor } = watch(); + const [{ loading, value: image, error }, renderImage] = useAsyncFn(async (imageUrl) => { + const response = await lastValueFrom(getBackendSrv().fetch({ url: imageUrl, responseType: 'blob' })); + return new Blob([response.data], { type: 'image/png' }); + }, []); + + const onRenderImageClick = async (data: ImageSettingsForm) => { + const { width, height, scaleFactor } = data; DashboardInteractions.generatePanelImageClicked({ width, height, @@ -59,9 +64,9 @@ export function SharePanelPreview({ title, imageUrl, buildUrl, disabled, theme } theme, shareResource: 'panel', }); - const response = await lastValueFrom(getBackendSrv().fetch({ url: imageUrl, responseType: 'blob' })); - return new Blob([response.data], { type: 'image/png' }); - }, [imageUrl, watch('width'), watch('height'), watch('scaleFactor'), theme]); + + await renderImage(imageUrl); + }; const onDownloadImageClick = () => { DashboardInteractions.downloadPanelImageClicked({ shareResource: 'panel' }); @@ -78,7 +83,7 @@ export function SharePanelPreview({ title, imageUrl, buildUrl, disabled, theme } Panel preview -
+