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

[tooltip] fix tootlip with bounds offset #204

Merged
merged 1 commit into from
Nov 29, 2017

Conversation

williaster
Copy link
Collaborator

🐛 Bug Fix

This PR fixes a pretty bad and somewhat esoteric bug for <TooltipWithBounds /> in the @vx/tooltip package. Since my PR that introduced optional padding/offsets for this component, it's been acting weird on the edges of containers:

@conglei and I debugged this earlier today and what we think is happening is that the tooltip width is being compressed on the edge of charts (when word-wrap is set to allow wrapping) like the pic below, making its width smaller and height larger (note this gif has boundary detection disabled).

This smaller width and larger height are reflected in the withBoundingClientRects we get, but it seems because the tooltip is actually offset from the edge of the chart it does not visually appear to change dimensions. This means that our calculation for the offset includes a smaller-than-actual-width and larger-than-actual-height, making the tooltip go all over (if you pay close attn to the broken gif, it's consistent with this).

The fix was to switch to using css transforms instead of top and left. We set top to 0 meaning that the withBoundingClientRects dimensions are always in sync with the rendered tooltip:

cc @techniq

@techniq
Copy link
Collaborator

techniq commented Nov 21, 2017

LGTM, and should have better perf by not requiring a layout or paint (https://csstriggers.com/transform) although I haven't benchmarked it.

Copy link
Member

@hshoff hshoff left a comment

Choose a reason for hiding this comment

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

LGTM

@hshoff hshoff added this to the v0.0.148 milestone Nov 29, 2017
@hshoff hshoff merged commit f382036 into airbnb:master Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants