Skip to content

Conversation

@ersin-erdal
Copy link
Contributor

@ersin-erdal ersin-erdal commented Nov 6, 2025

Resolves: #238028

Current reporting jobs get the dimensions of the element we want to screenshot in the params and uses them to set the viewport dimensions and the image dimensions. This causes the skewed images problem when there is another element next to the element we want to screenshot.
F.I.:
UI passes the element dimensions: 1200x760

  • When there is no another element next to the target element, viewport: 1200x760 and screenshot size 1200x760. No problem.

  • When there is an element (100px wide) next to the target element viewport: 1200x760, screenshot size becomes: 1100x760. And when we want to add that image back into a PDF we use the params we got from the UI: 1200x760. Therefore the image becomes stretched.

This PR solves this problem by using the real dimensions of the target element, by getting them during the execution.

To verify:

  • Generate a PDF report for a dashboard, the screenshot in it shouldn't be stretched.
  • Generate a PDF report for a dashboard in a solution view, the screenshot in it shouldn't be stretched.

    To use a solution view: Stack Management > spaces then edit the space you are in, Select a solution view other than classic
  • Generate a PDF report for a dashboard in a solution view with the new grid layout, the screenshot in it shouldn't be stretched.

    Same as the above just use the below config in your kibana.yml
feature_flags.overrides:
  core.chrome.layoutType: 'grid'

@ersin-erdal ersin-erdal added release_note:fix backport:skip This PR does not require backporting Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// Feature:Reporting:Screenshot Reporting issues pertaining to PNG/PDF file export labels Nov 6, 2025
@ersin-erdal ersin-erdal marked this pull request as ready for review November 10, 2025 12:25
@ersin-erdal ersin-erdal requested review from a team as code owners November 10, 2025 12:25
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

kibana-presentation changes LGTM - just an updated to a baseline snapshot image
code review only

@ersin-erdal ersin-erdal requested a review from Dosant November 13, 2025 09:52
Copy link
Member

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

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

LGTM, but I think we should wait for #242780 to be merged, so we can test PDF/print


const layout = new PreserveLayout({} as Size);

const testSpy = jest.spyOn(layout, 'setPdfImageSize');
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed this file is missing

  afterEach(() => {
    jest.resetAllMocks();
  });

Could you please add it?

import type { JobParamsProviderOptions } from '../share_context_menu';

const getBaseParams = (objectType: string) => {
const viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ Do we actually need the second part? I assume we don’t need to account for scrollbar width when taking screenshots

Suggested change
const viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
const viewportWidth = document.documentElement.clientWidth;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for the old browsers. Looks like document.documentElement.clientWidth doesn't work for some old browsers.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
reporting 125.8KB 126.0KB +219.0B

History

@ersin-erdal ersin-erdal merged commit acb1205 into elastic:main Nov 18, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Reporting:Screenshot Reporting issues pertaining to PNG/PDF file export release_note:fix Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Reporting] Report Skew with Grid Layout

6 participants