Make Tooltip use currentTarget instead of target when calculating the position

old
Ezequiel Schwartzman 2016-12-02 13:10:04 -05:00
parent b3f99348d4
commit 1e0aaec12c
2 changed files with 9 additions and 2 deletions

View File

@ -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);

View File

@ -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 <strong {...other}>{children}</strong>;
});
const TooltipStrongDirect = Tooltip('strong');
const ChipTooltip = Tooltip(Chip);
const TooltipTest = () => (
<section>
@ -23,6 +26,10 @@ const TooltipTest = () => (
floating
tooltip={<div><p>An example with</p><p>Multiline!</p></div>}
/>
<ChipTooltip tooltip='Dolor sit amet' tooltipPosition='top'>
<Avatar icon='home'/>
<span>Tooltip in a chip</span>
</ChipTooltip>
<TooltipInput tooltip='lorem ipsum...' />
<p>Lorem ipsum dolor sit amet, <TooltipStrong tooltip='This is a auto show tooltip'>consectetur</TooltipStrong> adipiscing elit.</p>
<p>