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] Fix editor value resetting at layout change #193516

Merged

Conversation

ElenaStoeva
Copy link
Contributor

@ElenaStoeva ElenaStoeva commented Sep 20, 2024

Summary

This PR fixes the bug where the editor input resets when we resize the page and the layout changes. The following fixes were applied:

  • The isVerticalLayout prop was moved one level down. This removes unnecessary rerendering of the editor when the layout is changed.
  • Allowed the localstorage value to be undefined. Undefined means that nothing is stored so we should display the default input. If an empty string is stored, we should display an empty editor.
  • Updates local storage with debounce every time when the editor input is changes. This ensures the editor input is not reset when the editor is rerendered.
  • Updates the local storage value to undefined if it is an empty string when data is being initialized at Main. This ensures that the default input is displayed when we switch between tabs/pages and the input is empty.

Before:

Screen.Recording.2024-09-20.at.08.44.56.mov

Now:

Screen.Recording.2024-09-23.at.12.32.55.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 Sep 20, 2024
@ElenaStoeva ElenaStoeva self-assigned this Sep 20, 2024
@ElenaStoeva ElenaStoeva requested a review from a team as a code owner September 20, 2024 07:50
@elasticmachine
Copy link
Contributor

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

@ElenaStoeva ElenaStoeva added the backport:skip This commit does not require backporting label Sep 20, 2024
@kibana-ci
Copy link
Collaborator

💚 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
console 208.0KB 208.1KB +97.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
console 44 43 -1

Total ESLint disabled count

id before after diff
console 46 45 -1

History

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

cc @ElenaStoeva

@ElenaStoeva ElenaStoeva added v9.0.0 backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) v8.16.0 and removed backport:skip This commit does not require backporting labels Sep 23, 2024
Copy link
Member

@sabarasaba sabarasaba left a comment

Choose a reason for hiding this comment

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

Tested locally, all bugs seem to have been patched and all works well again! Nice work @ElenaStoeva!

@ElenaStoeva ElenaStoeva merged commit 3b8e56f into elastic:main Sep 24, 2024
25 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 24, 2024
## Summary

This PR fixes the bug where the editor input resets when we resize the
page and the layout changes. The following fixes were applied:

- The `isVerticalLayout` prop was moved one level down. This removes
unnecessary rerendering of the editor when the layout is changed.
- Allowed the localstorage value to be undefined. Undefined means that
nothing is stored so we should display the default input. If an empty
string is stored, we should display an empty editor.
- Updates local storage with debounce every time when the editor input
is changes. This ensures the editor input is not reset when the editor
is rerendered.
- Updates the local storage value to `undefined` if it is an empty
string when data is being initialized at Main. This ensures that the
default input is displayed when we switch between tabs/pages and the
input is empty.

Before:

https://github.com/user-attachments/assets/a0535780-d75a-4df8-9e04-9d34b6f5f4f1

Now:

https://github.com/user-attachments/assets/7db46c2c-c35e-461f-99e8-b86c66fb6ae5

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 3b8e56f)
@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 Sep 24, 2024
…#193834)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Console] Fix editor value resetting at layout change
(#193516)](#193516)

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

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

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-24T08:56:47Z","message":"[Console]
Fix editor value resetting at layout change (#193516)\n\n##
Summary\r\n\r\nThis PR fixes the bug where the editor input resets when
we resize the\r\npage and the layout changes. The following fixes were
applied:\r\n\r\n- The `isVerticalLayout` prop was moved one level down.
This removes\r\nunnecessary rerendering of the editor when the layout is
changed.\r\n- Allowed the localstorage value to be undefined. Undefined
means that\r\nnothing is stored so we should display the default input.
If an empty\r\nstring is stored, we should display an empty editor.\r\n-
Updates local storage with debounce every time when the editor
input\r\nis changes. This ensures the editor input is not reset when the
editor\r\nis rerendered.\r\n- Updates the local storage value to
`undefined` if it is an empty\r\nstring when data is being initialized
at Main. This ensures that the\r\ndefault input is displayed when we
switch between tabs/pages and the\r\ninput is
empty.\r\n\r\nBefore:\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/a0535780-d75a-4df8-9e04-9d34b6f5f4f1\r\n\r\n\r\n\r\n\r\nNow:\r\n\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/7db46c2c-c35e-461f-99e8-b86c66fb6ae5\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"3b8e56fd34264963bcdbd84110f0cb1fc12651c4","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana
Management","release_note:skip","v9.0.0","backport:prev-minor","v8.16.0"],"title":"[Console]
Fix editor value resetting at layout
change","number":193516,"url":"https://github.com/elastic/kibana/pull/193516","mergeCommit":{"message":"[Console]
Fix editor value resetting at layout change (#193516)\n\n##
Summary\r\n\r\nThis PR fixes the bug where the editor input resets when
we resize the\r\npage and the layout changes. The following fixes were
applied:\r\n\r\n- The `isVerticalLayout` prop was moved one level down.
This removes\r\nunnecessary rerendering of the editor when the layout is
changed.\r\n- Allowed the localstorage value to be undefined. Undefined
means that\r\nnothing is stored so we should display the default input.
If an empty\r\nstring is stored, we should display an empty editor.\r\n-
Updates local storage with debounce every time when the editor
input\r\nis changes. This ensures the editor input is not reset when the
editor\r\nis rerendered.\r\n- Updates the local storage value to
`undefined` if it is an empty\r\nstring when data is being initialized
at Main. This ensures that the\r\ndefault input is displayed when we
switch between tabs/pages and the\r\ninput is
empty.\r\n\r\nBefore:\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/a0535780-d75a-4df8-9e04-9d34b6f5f4f1\r\n\r\n\r\n\r\n\r\nNow:\r\n\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/7db46c2c-c35e-461f-99e8-b86c66fb6ae5\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"3b8e56fd34264963bcdbd84110f0cb1fc12651c4"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193516","number":193516,"mergeCommit":{"message":"[Console]
Fix editor value resetting at layout change (#193516)\n\n##
Summary\r\n\r\nThis PR fixes the bug where the editor input resets when
we resize the\r\npage and the layout changes. The following fixes were
applied:\r\n\r\n- The `isVerticalLayout` prop was moved one level down.
This removes\r\nunnecessary rerendering of the editor when the layout is
changed.\r\n- Allowed the localstorage value to be undefined. Undefined
means that\r\nnothing is stored so we should display the default input.
If an empty\r\nstring is stored, we should display an empty editor.\r\n-
Updates local storage with debounce every time when the editor
input\r\nis changes. This ensures the editor input is not reset when the
editor\r\nis rerendered.\r\n- Updates the local storage value to
`undefined` if it is an empty\r\nstring when data is being initialized
at Main. This ensures that the\r\ndefault input is displayed when we
switch between tabs/pages and the\r\ninput is
empty.\r\n\r\nBefore:\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/a0535780-d75a-4df8-9e04-9d34b6f5f4f1\r\n\r\n\r\n\r\n\r\nNow:\r\n\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/7db46c2c-c35e-461f-99e8-b86c66fb6ae5\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"3b8e56fd34264963bcdbd84110f0cb1fc12651c4"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <[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: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.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants