From 1e0aaec12c6e4e64998d1cfc0a63d88459c54e3e Mon Sep 17 00:00:00 2001 From: Ezequiel Schwartzman Date: Fri, 2 Dec 2016 13:10:04 -0500 Subject: [PATCH] Make Tooltip use currentTarget instead of target when calculating the position --- components/tooltip/Tooltip.js | 4 ++-- spec/components/tooltip.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/tooltip/Tooltip.js b/components/tooltip/Tooltip.js index 3b92b23e..34ee5419 100644 --- a/components/tooltip/Tooltip.js +++ b/components/tooltip/Tooltip.js @@ -152,7 +152,7 @@ const tooltipFactory = (options = {}) => { }; handleMouseEnter = (event) => { - this.activate(this.calculatePosition(event.target)); + this.activate(this.calculatePosition(event.currentTarget)); if (this.props.onMouseEnter) this.props.onMouseEnter(event); }; @@ -167,7 +167,7 @@ const tooltipFactory = (options = {}) => { } if (this.props.tooltipShowOnClick && !this.state.active) { - this.activate(this.calculatePosition(event.target)); + this.activate(this.calculatePosition(event.currentTarget)); } if (this.props.onClick) this.props.onClick(event); diff --git a/spec/components/tooltip.js b/spec/components/tooltip.js index d2285a07..419955e2 100644 --- a/spec/components/tooltip.js +++ b/spec/components/tooltip.js @@ -2,6 +2,8 @@ import React from 'react'; import Button from '../../components/button'; import Input from '../../components/input'; import Tooltip from '../../components/tooltip'; +import Chip from '../../components/chip'; +import Avatar from '../../components/avatar'; const TooltipButton = Tooltip(Button); const TooltipInput = Tooltip(Input); @@ -10,6 +12,7 @@ const TooltipStrong = Tooltip(({children, ...other}) => { return {children}; }); const TooltipStrongDirect = Tooltip('strong'); +const ChipTooltip = Tooltip(Chip); const TooltipTest = () => (
@@ -23,6 +26,10 @@ const TooltipTest = () => ( floating tooltip={

An example with

Multiline!

} /> + + + Tooltip in a chip +

Lorem ipsum dolor sit amet, consectetur adipiscing elit.