Skip to content

Commit

Permalink
fix(tooltip): merge children props
Browse files Browse the repository at this point in the history
  • Loading branch information
jigsawye committed Mar 28, 2019
1 parent 9de4570 commit 50a0952
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/tailor-ui-lab/src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import React, {
useState,
} from 'react';
import debounce from 'lodash.debounce';
import { animated } from 'react-spring';

import { Position, Positioner, Positions } from 'tailor-ui';
import { animated } from 'react-spring';
import { mergeEventProps } from '@tailor-ui/utils';

import { StyledTooltip, StyledTooltipProps } from './styles';

Expand Down Expand Up @@ -146,15 +146,15 @@ const Tooltip: FunctionComponent<TooltipProps> = ({
}
};

// TODO: compose events
const renderChildren = ({ ref }: { ref: RefObject<HTMLElement> }) => {
if (children instanceof Function) {
return children({
ref,
bind: {
onMouseEnter: handleOpen,
onMouseLeave: handleClose,
},
bind: (props: any) =>
mergeEventProps(props, {
onMouseEnter: handleOpen,
onMouseLeave: handleClose,
}),
});
}

Expand All @@ -164,8 +164,10 @@ const Tooltip: FunctionComponent<TooltipProps> = ({

return cloneElement(children, {
ref,
onMouseEnter: handleOpen,
onMouseLeave: handleClose,
...mergeEventProps(children.props, {
onMouseEnter: handleOpen,
onMouseLeave: handleClose,
}),
});
};

Expand Down

0 comments on commit 50a0952

Please sign in to comment.