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

[Lens] Fix label input debouncing #84121

Merged
merged 2 commits into from
Nov 25, 2020

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Nov 23, 2020

Fixes #83818

In some places where debounced inputs where used, we were listening for changes coming from upstream as well using an effect hook. This helps if the same state is changed somewhere else and the input needs to be updated, but it can cause the weird typing issue seen in the original issue, because of this process:
Scenario: User types "abc", waits for 280ms before typing "de", then waits for 280ms again to type "fg"
What they see: "abcde" appearing, flipping back to "abc", "abcfg" appearing, switching to "abcde", then switching back to "abcfg"

  • After 256ms the debounce kicks in and pushes the changes to the root
  • It takes a while for react to update the whole tree (and it happens async), so the root change reaches the input again after ~300ms
  • The user already typed "de", but the root change gets applied, setting the input to "abc"
  • The "de" disappears, but it still stored in the debounced callback, and after 256ms "abcde" gets pushed to the root
  • In the meantime, the user typed "fg", so the input is set to "abcfg", which is also stored in the debounced callback
  • Now, "abcde" arrives from the root update, and the input is set to "abcde" (basically removing "fg")
  • After further 256ms, "abcfg" is pushed to the root, and the input changes once again to "abcfg"

Removing the useEffect updating on root state changes fixes this behavior, but introduces a theoretical bug of not reflecting a change somewhere else. However I reviewed the places these inputs are used and we don't have such a case yet. So this is fine for now to fix the bug at hand and we can come back to solve it better once we refactor the state mangement.

@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
lens 935.0KB 934.7KB -301.0B

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

@flash1293 flash1293 marked this pull request as ready for review November 24, 2020 08:55
@flash1293 flash1293 requested a review from a team November 24, 2020 08:55
@flash1293 flash1293 added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Nov 24, 2020
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@mbondyra mbondyra left a comment

Choose a reason for hiding this comment

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

tested in Chrome, works fine 👍

@flash1293 flash1293 merged commit 09e326e into elastic:master Nov 25, 2020
flash1293 added a commit to flash1293/kibana that referenced this pull request Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] debounced 'Display name' component doesn't work performantly
4 participants