Skip to content

[8.17] [Lens][Reporting] Add custom CSS for Lens screenshots (#228603)#229658

Merged
nickofthyme merged 2 commits intoelastic:8.17from
nickofthyme:backport/8.17/pr-228603
Jul 30, 2025
Merged

[8.17] [Lens][Reporting] Add custom CSS for Lens screenshots (#228603)#229658
nickofthyme merged 2 commits intoelastic:8.17from
nickofthyme:backport/8.17/pr-228603

Conversation

@nickofthyme
Copy link
Contributor

Backport

This will backport the following commits from main to 8.17:

Questions ?

Please refer to the Backport tool documentation

## Summary

Fix Lens screenshotting issues:

- apply `hide-for-sharing` class to the search bar in lens
- added two specialized styles for Lens workspace to fix the current
positioning error by removing the container display flex and
padding/borders.

What is actually doing is removing horizontal and vertical spacing,
caused by the current flex layout applied.

I've tried to tracking down a bit more why exactly this is happening,
but I didn't want to touch much the current reporting logic. From what I
saw the reporting for PNG works like that:
1- the service receive, together with other info, the current `layout`
from the browser page (consisting in the size of the current
visualization)
2- it creates a puppeter page with a viewport of the same size of the
`layout.width` and a `scaleFactor`
3- the setup step, waits for elements to be on the screen, applies the
and the render is completed
4- we detect element positions and sizing with a headless-browser size
call to getBoundingBoxRect()
5- the viewport is now is changed again (actually just vertically) to
cover the entire height from the top to the bottom of the chart
(computed at step 4)
6- a screenshot request to the headless browser covering clipping the
screen to just the element position, size.

I believe the best way to approach this in the future is, instead of
changing the viewport and and clipping where the element is, we can
apply a `position:fixed` push the chart to the top/left corner and
applying the original `layout` size to the screenshotting element. In
this way we are sure that the sizing and clipping is always perfect.

fix elastic#227930
fix elastic#219297

---------

Co-authored-by: Nick Partridge <nicholas.partridge@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 46808d6)

# Conflicts:
#	x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx
@nickofthyme nickofthyme added the backport This PR is a backport of another PR label Jul 28, 2025
@nickofthyme nickofthyme enabled auto-merge (squash) July 28, 2025 14:23
@nickofthyme nickofthyme requested a review from markov00 July 28, 2025 14:25
@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
lens 1.5MB 1.5MB +93.0B
unifiedSearch 340.3KB 340.3KB +19.0B
total +112.0B
@nickofthyme nickofthyme merged commit 174c2a7 into elastic:8.17 Jul 30, 2025
8 checks passed
@nickofthyme nickofthyme deleted the backport/8.17/pr-228603 branch July 30, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

4 participants