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

[Console Monaco Migration] Handle editor resize #180494

Conversation

ElenaStoeva
Copy link
Contributor

Closes #180216

Summary

This PR adds resize handling for the editor and the output panel in Console Monaco.

Screen.Recording.2024-04-10.at.16.49.18.mov

@ElenaStoeva ElenaStoeva added Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes labels Apr 10, 2024
@ElenaStoeva ElenaStoeva self-assigned this Apr 10, 2024
@ElenaStoeva
Copy link
Contributor Author

/ci

@ElenaStoeva
Copy link
Contributor Author

/ci

Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this, @ElenaStoeva!
As discussed, I had a look at your solution and I was wondering if you have tried using automaticLayout: true mentioned in this StackOverflow question? Could you please check if that could work for our use case? If not, we can use editor.layout but maybe we could put the code for both input and output editors in a reusable function? Also for both solutions, we need to check for performance: for example, add debounce for editor.layout calls, as it is implemented right now, it's being called many times while the user is still resizing the window.

@ElenaStoeva
Copy link
Contributor Author

Thanks a lot for working on this, @ElenaStoeva! As discussed, I had a look at your solution and I was wondering if you have tried using automaticLayout: true mentioned in this StackOverflow question? Could you please check if that could work for our use case? If not, we can use editor.layout but maybe we could put the code for both input and output editors in a reusable function? Also for both solutions, we need to check for performance: for example, add debounce for editor.layout calls, as it is implemented right now, it's being called many times while the user is still resizing the window.

Thanks for the review @yuliacech! Yes, I tried using this option alone but it didn't work well - as the resizer is being moved, it bounces back and forth:

Screen.Recording.2024-04-16.at.10.43.28.mov

I played around using the automaticLayout option or the resize checker and I think it works best when we use the resize checker only in the editor and both the resize checker and the automaticLayout option in the output panel.

Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the explanation, @ElenaStoeva! The resizer works as expected 👍

@ElenaStoeva ElenaStoeva marked this pull request as ready for review April 25, 2024 09:20
@ElenaStoeva ElenaStoeva requested review from a team as code owners April 25, 2024 09:20
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

@ElenaStoeva
Copy link
Contributor Author

/ci

divElement: HTMLDivElement,
editor: monaco.editor.IStandaloneCodeEditor
) => {
resizeChecker.current = new ResizeChecker(divElement);
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest to check if there is already a resizeChecker.current and destroy it if there is one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @Dosant! Added this check with f02739b.

@ElenaStoeva ElenaStoeva enabled auto-merge (squash) April 25, 2024 10:05
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
console 247 248 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/code-editor 15 16 +1

Async chunks

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

id before after diff
console 440.6KB 441.2KB +624.0B
Unknown metric groups

API count

id before after diff
@kbn/code-editor 38 39 +1

History

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

cc @ElenaStoeva

@ElenaStoeva ElenaStoeva merged commit 12ecb70 into elastic:main Apr 25, 2024
18 checks passed
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels Apr 25, 2024
kpatticha pushed a commit to kpatticha/kibana that referenced this pull request Apr 26, 2024
@ElenaStoeva ElenaStoeva deleted the console-monaco-migration/add-resize-handling branch June 24, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Console Dev Tools Console Feature release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Console Monaco migration] Handle editor resize
6 participants