-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Reporting] Use the real dimensions when taking a screenshot #242127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Reporting] Use the real dimensions when taking a screenshot #242127
Conversation
|
Pinging @elastic/response-ops (Team:ResponseOps) |
nreese
left a comment
There was a problem hiding this 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
pmuellr
left a comment
There was a problem hiding this 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'); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
| const viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); | |
| const viewportWidth = document.documentElement.clientWidth; |
There was a problem hiding this comment.
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.
💚 Build Succeeded
Metrics [docs]Async chunks
History
|
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:
To use a solution view:
Stack Management > spacesthen edit the space you are in,Select a solution view other than classicSame as the above just use the below config in your kibana.yml