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

Use EuiResizableContainer in visualize #86934

Merged
merged 23 commits into from
Feb 22, 2021

Conversation

sulemanof
Copy link
Contributor

@sulemanof sulemanof commented Dec 24, 2020

Summary

Resolves #84343

Replace shared PanelsContainer component from kibana_reactplugin with EuiResizableContainer in Visualize default editor.

image

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@sulemanof sulemanof force-pushed the feat/resizable_container_editor branch from 5409fac to 96c9b50 Compare January 25, 2021 14:30
@sulemanof
Copy link
Contributor Author

Hey @andreadelrio
Highly need your assistance in this PR 🙏

The pr is intended to use EuiResizableContainer in visualize app.

This was working fine initially, but after the changes happened here elastic/eui#3978
I faced a problem - it stops rendering a visualization in a left panel of the container.
The rendering process from kibana side is (see the src/plugins/vis_default_editor/public/default_editor.tsx):
there is a panel with a ref in react dom tree ->
Screen Shot 2021-01-25 at 17 43 04

and here is an effect responsible for rendering a particular visualization in a DOM node:

Screen Shot 2021-01-25 at 17 46 00

I did a research and found the reason: the DOM node was unmounted from the DOM during the render, and this happened due to a subscription to resize in eui src/components/resizable_container/resizable_container.tsx

Screen Shot 2021-01-25 at 17 50 28

The code re-initialize the container couple of times while render (we are using lazy loading and the container doesn't have its real dimensions set initially since it is hidden by display: none under the hood of implementation and the loading spinner is shown) and removes the DOM node from the DOM, which is responsible for rendering a vis in the chain of next renderings.

Disabling the highlighted lines of code in the eui resolves the problem.

I would really appreciate your help on this issue 🙏
You could text me in slack for details if needed 🙂

@andreadelrio
Copy link
Contributor

Pinging @thompsongl

@thompsongl
Copy link
Contributor

elastic/eui#4447 Should get you moving again. Note that it'll take some time after it merges for the changes to 1) be part of an EUI release and 2) have that release land in Kibana. If you need it sooner to hit a deadline, let me know and we can work it out.

@sulemanof
Copy link
Contributor Author

@elasticmachine merge upstream

@sulemanof sulemanof force-pushed the feat/resizable_container_editor branch from a339e21 to c7ab156 Compare February 15, 2021 12:47
@sulemanof
Copy link
Contributor Author

Thanks @thompsongl for helping out with elastic/eui#4447 to fix initialization problem.
The replacement is ready to be reviewed now.
The only question I have left now is the problem of usage the EUI built-in Collapsible panels for the editor case.
The reason is the editor has two directions layout: both horizontal and vertical (on phone & tablet screens - xs, s, m eui dimensions):

Screen.Recording.2021-02-15.at.16.02.46.mov

So the current implementation uses EuiResizableContainer basic horizontal layout, custom collapsible button and custom style changes on small screens.
I would like the design to take a look, maybe you'll have a new layout vision or anything else.
cc @cchaos @chandlerprall @andreadelrio

@sulemanof
Copy link
Contributor Author

sulemanof commented Feb 18, 2021

@cchaos
The collapsibility on small screens is presented in the editor since at least kibana 6.x
This is used to collapse the editor panel and make a visualization "full screen".
The resizability is not available on small screens.

  • small screen, expanded editor panel

    Screen Shot 2021-02-18 at 17 23 53
  • small screen, collapsed editor panel

    Screen Shot 2021-02-18 at 17 24 30

Do you mean we need to get rid of this feature?
Could you please check it out to see if it meets your expectations?

In this PR I fully preserved the existing editor behavior, but in the comment above just highlighted that I can't fully use EuiResizableContainer built-in features.

@sulemanof sulemanof marked this pull request as ready for review February 18, 2021 15:13
@sulemanof sulemanof requested a review from a team February 18, 2021 15:13
@sulemanof sulemanof requested a review from a team as a code owner February 18, 2021 15:13
@sulemanof sulemanof added Feature:Vis Editor Visualization editor issues release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.13.0 v8.0.0 labels Feb 18, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@cchaos
Copy link
Contributor

cchaos commented Feb 18, 2021

From your before/after screens, it seems that the new implementation is the same as the previous. I'd just leave it as-is for this PR then, and then circle back with @elastic/kibana-design for help with figuring out if there should be any layout changes.

Another quick fix is that collapsible option of EuiResizableContainer comes with the option to change from horizontal to vertical, also in turn changing the direction of the icon. You may want to consider changing this direction once the screen sizes down.

@sulemanof
Copy link
Contributor Author

Another quick fix is that collapsible option of EuiResizableContainer comes with the option to change from horizontal to vertical, also in turn changing the direction of the icon. You may want to consider changing this direction once the screen sizes down.

Unfortunately, EuiResizableContainer does NOT support changing horizontal/vertical layout dynamically, it provides only one direction layout initially. That's why I left the custom styles for small screens and collapse button.

@cchaos
Copy link
Contributor

cchaos commented Feb 19, 2021

Yep, you're right. I tried to dynamically change the direction based on the window size, but it errors out. I created an EUI issue: elastic/eui#4555

Copy link
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

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

+1 to the idea of circling back to this in the future, post-merge and after an EUI fix becomes available.

Approving the changes with that in mind.

@@ -1,45 +1,25 @@
.visEditor--default {
height: 1px;
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to have a comment here explaining the reason as it will undoubtedly stand out to future reviewers of this file.

@sulemanof
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor

@elasticmachine run elasticsearch-ci/docs

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

I tested it locally on Chrome, FF and Safari and it works fine. Code LGTM 🙂

@sulemanof
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/docs

@kibanamachine
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
visDefaultEditor 246.2KB 241.5KB -4.6KB

History

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

@stratoula
Copy link
Contributor

@elasticmachine run elasticsearch-ci/docs

@sulemanof sulemanof merged commit d0a7ca2 into elastic:master Feb 22, 2021
@sulemanof sulemanof deleted the feat/resizable_container_editor branch February 22, 2021 14:20
sulemanof pushed a commit to sulemanof/kibana that referenced this pull request Feb 22, 2021
* Use EuiResizableContainer

* Code cleanup

* Memoize the sidebar for performance boost

* Prevent mouseLeave event

* Downgrade eui to 30.6.0

* Revert eui downgrade

* Update styles

* Render embeddable after a timeout

* Fix printing

* Fix resizer functional test

* Create an explicit layout breakpoint

* Remove extra code

* Update layout styles

* Add a note of using height: 1px

Co-authored-by: Kibana Machine <[email protected]>
sulemanof pushed a commit that referenced this pull request Feb 23, 2021
* Use EuiResizableContainer

* Code cleanup

* Memoize the sidebar for performance boost

* Prevent mouseLeave event

* Downgrade eui to 30.6.0

* Revert eui downgrade

* Update styles

* Render embeddable after a timeout

* Fix printing

* Fix resizer functional test

* Create an explicit layout breakpoint

* Remove extra code

* Update layout styles

* Add a note of using height: 1px

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Vis Editor Visualization editor issues release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[VisEditor] Replace the current resizer with the EuiResizableContainer
8 participants