-
Notifications
You must be signed in to change notification settings - Fork 121
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
fix: tooltip container scroll issue #647
Conversation
- refactor tooltip logic to account for portal - seperate tooltip and tooltip portal components - update tests to check for new portal condition - set max tooltip width from component js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM! Tested locally in Chrome - no scrollbar in the playground nor in the stories when squishing the browser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked in our storybook and also on the PR playground and it doesn't seem to solve the problems once for all.
- on the playground, (treemap example) if you get rid of the legend the scroll bar will appear
- the same happens on the storybook for treemap, see:
I've open a partial PR with a fix for horizontal charts: nickofthyme#1
Codecov Report
@@ Coverage Diff @@
## master #647 +/- ##
==========================================
+ Coverage 72.54% 72.82% +0.28%
==========================================
Files 245 261 +16
Lines 8158 8446 +288
Branches 1597 1645 +48
==========================================
+ Hits 5918 6151 +233
- Misses 2207 2258 +51
- Partials 33 37 +4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM tested locally and seems to work perfectly.
I've left a few minor comments, that are not required for merge
padding = 10, | ||
): { | ||
left: string | null; | ||
top: string | null; | ||
anchor: 'left' | 'right'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can use Position.Left
and Position.Right
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | ||
* @unit px | ||
*/ | ||
static maxWidth = 256; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
static maxWidth = 256; | |
static MAX_WIDTH = 256; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | ||
* @unit px | ||
*/ | ||
static maxWidth = 256; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
static maxWidth = 256; | |
static MAX_WIDTH = 256; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** the tooltip anchor computed position not adjusted within chart bounds */ | ||
anchorPosition: TooltipAnchorPosition, | ||
): { | ||
left: string | null; | ||
top: string | null; | ||
anchor: 'left' | 'right'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Position.Left | Position.Right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [19.0.0](v18.4.2...v19.0.0) (2020-04-28) ### Bug Fixes * tooltip container scroll issue ([#647](#647)) ([f411771](f411771)) * **annotations:** fix alignment at the edges ([#641](#641)) ([43c5a59](43c5a59)), closes [#586](#586) ### Features * shift click legend items & partition legend hover ([#648](#648)) ([ed91744](ed91744)) * **brush:** add multi axis brushing ([#625](#625)) ([9e49534](9e49534)), closes [#587](#587) [#620](#620) ### BREAKING CHANGES * **brush:** The type used by the `BrushEndListener` is now in the following form `{ x?: [number, number]; y?: Array<{ groupId: GroupId; values: [number, number]; }> }` where `x` contains an array of `[min, max]` values, and the `y` property is an optional array of objects, containing the `GroupId` and the values of the brush for that specific axis. * **annotations:** In the rectangular annotation, the y0 parameter of the coordinates now refers to the minimum value and the y1 value refers to the maximum value of the y domain.
🎉 This PR is included in version 19.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [19.0.0](elastic/elastic-charts@v18.4.2...v19.0.0) (2020-04-28) ### Bug Fixes * tooltip container scroll issue ([opensearch-project#647](elastic/elastic-charts#647)) ([f0af34b](elastic/elastic-charts@f0af34b)) * **annotations:** fix alignment at the edges ([opensearch-project#641](elastic/elastic-charts#641)) ([c698d08](elastic/elastic-charts@c698d08)), closes [opensearch-project#586](elastic/elastic-charts#586) ### Features * shift click legend items & partition legend hover ([opensearch-project#648](elastic/elastic-charts#648)) ([cf15ca1](elastic/elastic-charts@cf15ca1)) * **brush:** add multi axis brushing ([opensearch-project#625](elastic/elastic-charts#625)) ([382cb14](elastic/elastic-charts@382cb14)), closes [opensearch-project#587](elastic/elastic-charts#587) [opensearch-project#620](elastic/elastic-charts#620) ### BREAKING CHANGES * **brush:** The type used by the `BrushEndListener` is now in the following form `{ x?: [number, number]; y?: Array<{ groupId: GroupId; values: [number, number]; }> }` where `x` contains an array of `[min, max]` values, and the `y` property is an optional array of objects, containing the `GroupId` and the values of the brush for that specific axis. * **annotations:** In the rectangular annotation, the y0 parameter of the coordinates now refers to the minimum value and the y1 value refers to the maximum value of the y domain.
Summary
Fixes tooltip render issue
fixes #596
Temporary fix
For really narrow charts where the tooltip cannot fit on the right nor the left, a temporary fix was added to limit the width of the tooltip portal to a max of 70% of the chart elements width to limit hiding the tooltip on the left. This is temporary until a more robust positioning logic is add in #651.
One issue with this approach is that the tooltip will go out of the element on the right for values in the center of the chart. However, this will not cause the scrollbars to show as described in #596.
This issue can also be seen with relatively normal widths where the tooltip portal does not fit in the space but the visible tooltip does, creating an unnecessary flip to the left side, which might cause the tooltip to appear outside of the element.
Root cause
Tooltips rendered towards the right edge of the chart container would compute if the tooltip "fits" based on the
.echTooltip
element and not the#echTooltipContainerPortal
element. Notice the red bar rendered behind the tooltip as the#echTooltipContainerPortal
element. Thus, when the.echTooltip
element width is less than that of the#echTooltipContainerPortal
the element will still render on the right but the#echTooltipContainerPortal
created an invisible additional width that pushed the tooltip off the page.The fix is to just account for the
#echTooltipContainerPortal
element width in the "fitting" calculation but still use the.echTooltip
element width for final positioning.Checklist
Delete any items that are not applicable to this PR.
src/index.ts
(and stories only import from../src
except for test data & storybook)