Skip to content
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

[Vega] Fix element sizing issues in fullscreen mode #194330

Merged
merged 11 commits into from
Oct 7, 2024

Conversation

nickofthyme
Copy link
Contributor

@nickofthyme nickofthyme commented Sep 27, 2024

Summary

Fixes #194011 where a Vega visualization does not respect the enclosing element dimensions.

Fixes #194861 where resizing vega vis panel fails to update to the latest panel dimensions causing scroll bars.

Details

This issue stems from changes in #181543 to remove jQuery, specifically these changes. The issue is that $(element).width() was replaced with element.getBoundingClientRect().width. In most cases these 2 values should be the same, see Determining the dimensions of elements, but here for some reason they return different values.

Zight.Recording.2024-09-27.at.12.03.43.PM.mp4

Notice the size of the chart is the same in both the normal and fullscreen modes, without scrollbars.

Checklist

@nickofthyme nickofthyme added release_note:fix Feature:Vega Vega visualizations Team:Visualizations Visualization editors, elastic-charts and infrastructure backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Sep 27, 2024
@nickofthyme nickofthyme requested a review from a team as a code owner September 27, 2024 17:05
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

- update tests to use client dimensions
- covert test file to ts
- update types for test file
Comment on lines 296 to 297
const width = Math.floor(Math.max(0, dimensions?.width ?? this._container.clientWidth));
const height = Math.floor(Math.max(0, dimensions?.height ?? this._container.clientHeight));
Copy link
Member

Choose a reason for hiding this comment

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

I played a bit with the PR but I see the same issue (scrollbars visible) if you just resize the panel. The PR fixes when switching to full screen, but it doesn't work for the panel resize.
I'm not sure if that was also the previous behaviour

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I've seen that before too where we are throttling the size update. I'll check with older versions and see if it's the same there.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that's the reason? throttling? if so we just need to just to use a debounce strategy instead of throttling.

Copy link
Contributor Author

@nickofthyme nickofthyme Oct 3, 2024

Choose a reason for hiding this comment

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

Ok I switched the resize to debounce in 0b2d976.

Throttle

Zight Recording 2024-10-03 at 11 41 13 AM

Debounce

Zight Recording 2024-10-03 at 11 40 21 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing debounce fixes this...

Zight Recording 2024-10-07 at 12 49 39 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another issue I've seen with both throttle and debounce, is when the panel is sized very quickly. It basically lock in the dimensions before the latest update.

Zight Recording 2024-10-03 at 12 13 49 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a huge issue but it appears most visualizations are no longer debouncing resize or very little, including Lens. Should we remove the throttle/debounce altogether in vega?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also the debounce prevents re-rendering on long slow resizing of the panel.

Copy link
Member

@markov00 markov00 Oct 4, 2024

Choose a reason for hiding this comment

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

It's not a huge issue but it appears most visualizations are no longer debouncing resize or very little, including Lens. Should we remove the throttle/debounce altogether in vega?

I believe we can remove it, resizing is not an operation that a user does continuously so it is safe even if it's triggered quickly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in 6965c17

@kibana-ci
Copy link
Collaborator

kibana-ci commented Oct 3, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #1 / VegaVisualizations VegaVisualization - basics should show vegalite graph and update on resize (may fail in dev env)
  • [job] [logs] Jest Tests #1 / VegaVisualizations VegaVisualization - basics should show vegalite graph and update on resize (may fail in dev env)

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
visTypeVega 1.8MB 1.8MB -54.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
visTypeVega 6 7 +1

Total ESLint disabled count

id before after diff
visTypeVega 6 7 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@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
visTypeVega 1.8MB 1.8MB -119.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
visTypeVega 6 7 +1

Total ESLint disabled count

id before after diff
visTypeVega 6 7 +1

@nickofthyme nickofthyme merged commit 55c2fd7 into elastic:main Oct 7, 2024
30 checks passed
@nickofthyme nickofthyme deleted the fix-vega-fullscreen-sizing branch October 7, 2024 22:20
@nickofthyme nickofthyme changed the title [Vega] Fix element sizing for fullscreen mode [Vega] Fix element sizing issues in fullscreen mode Oct 7, 2024
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11224911060

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 7, 2024
- Fixes elastic#194011 where a Vega visualization does not respect the enclosing
element dimensions.
- Fixes elastic#194861 where resizing Vega visualization panel fails to update to the
latest panel dimensions causing scroll bars.

(cherry picked from commit 55c2fd7)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 8, 2024
…195328)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Vega] Fix element sizing issues in fullscreen mode
(#194330)](#194330)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-07T22:20:27Z","message":"[Vega]
Fix element sizing issues in fullscreen mode (#194330)\n\n- Fixes
#194011 where a Vega visualization does not respect the
enclosing\r\nelement dimensions.\r\n- Fixes #194861 where resizing Vega
visualization panel fails to update to the\r\nlatest panel dimensions
causing scroll
bars.","sha":"55c2fd7fc1ef292961d5d69d20d1711b1fbbd468","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Vega","Team:Visualizations","v9.0.0","backport:prev-minor"],"title":"[Vega]
Fix element sizing issues in fullscreen
mode","number":194330,"url":"https://github.com/elastic/kibana/pull/194330","mergeCommit":{"message":"[Vega]
Fix element sizing issues in fullscreen mode (#194330)\n\n- Fixes
#194011 where a Vega visualization does not respect the
enclosing\r\nelement dimensions.\r\n- Fixes #194861 where resizing Vega
visualization panel fails to update to the\r\nlatest panel dimensions
causing scroll
bars.","sha":"55c2fd7fc1ef292961d5d69d20d1711b1fbbd468"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194330","number":194330,"mergeCommit":{"message":"[Vega]
Fix element sizing issues in fullscreen mode (#194330)\n\n- Fixes
#194011 where a Vega visualization does not respect the
enclosing\r\nelement dimensions.\r\n- Fixes #194861 where resizing Vega
visualization panel fails to update to the\r\nlatest panel dimensions
causing scroll
bars.","sha":"55c2fd7fc1ef292961d5d69d20d1711b1fbbd468"}}]}] BACKPORT-->

Co-authored-by: Nick Partridge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Vega Vega visualizations release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.16.0 v9.0.0
Projects
None yet
5 participants