Skip to content

[Lens] Fix label input debouncing#84121

Merged
flash1293 merged 2 commits intoelastic:masterfrom
flash1293:lens/fix-debouncing
Nov 25, 2020
Merged

[Lens] Fix label input debouncing#84121
flash1293 merged 2 commits intoelastic:masterfrom
flash1293:lens/fix-debouncing

Conversation

@flash1293
Copy link
Copy Markdown
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
Copy Markdown
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 Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// label Nov 24, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@flash1293 flash1293 requested a review from mbondyra November 24, 2020 08:55
Copy link
Copy Markdown
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 Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// 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