mirror of
https://github.com/nickzuber/meteorite.git
synced 2024-09-11 11:36:03 +03:00
Improve tooltip being unmounted
This commit is contained in:
parent
38f5db20a3
commit
71c45adb98
@ -53,7 +53,7 @@ class Tooltip extends React.Component {
|
|||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseLeave = () => {
|
removeTooltip = () => {
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
const tooltipElement = this.getTooltipElement();
|
const tooltipElement = this.getTooltipElement();
|
||||||
if (tooltipElement) {
|
if (tooltipElement) {
|
||||||
@ -64,16 +64,18 @@ class Tooltip extends React.Component {
|
|||||||
render () {
|
render () {
|
||||||
return this.props.children({
|
return this.props.children({
|
||||||
onMouseEnter: this.onMouseEnter,
|
onMouseEnter: this.onMouseEnter,
|
||||||
onMouseLeave: this.onMouseLeave,
|
onMouseLeave: this.removeTooltip,
|
||||||
|
onMouseDown: this.removeTooltip,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const withTooltip = WrappedComponent => ({tooltip, tooltipOffsetX, tooltipOffsetY, ...props}) => (
|
export const withTooltip = WrappedComponent => ({tooltip, tooltipOffsetX, tooltipOffsetY, ...props}) => (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
message={tooltip}
|
message={tooltip}
|
||||||
tooltipOffsetX={tooltipOffsetX}
|
tooltipOffsetX={tooltipOffsetX}
|
||||||
tooltipOffsetY={tooltipOffsetY}>
|
tooltipOffsetY={tooltipOffsetY}
|
||||||
|
>
|
||||||
{mouseEvents => tooltip ? (
|
{mouseEvents => tooltip ? (
|
||||||
<WrappedComponent {...props} {...mouseEvents} />
|
<WrappedComponent {...props} {...mouseEvents} />
|
||||||
) : (
|
) : (
|
||||||
|
Loading…
Reference in New Issue
Block a user