Prevent EuiToolTip from destroying & recreating its children *every* render #4174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
As reported over slack, if an EuiComboBox is wrapped by an EuiToolTip, the virtualized list scrolling resets:
This is caused by the tooltip cloning its children every render pass, causing React to unmount the previous children and remount the "new" one, which resets the scroll position. The root of that root is the mouseover/blur event handling within tooltip doesn't understand portals (which the options list is).
My proposal here caches the result from cloning of
children
until it changes again - so any re-rendering of the parent component will re-trigger this same issue, but it prevents changes made to tooltip's internal state from destroying everything.A side effect is that the
aria-describedby
value is present at all times, which may or may not anger @myasonik and will trigger a lot of snapshot updates (including the failing CI on this PR, I left the snapshots unchanged to help show the difference).I am very open to other ideas.
Checklist