Skip to content

Commit

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

import {
Heading,
Position,
Expand All @@ -20,6 +18,8 @@ import {
useClickOutside,
useKeydown,
} from 'tailor-ui';
import { animated } from 'react-spring';
import { mergeEventProps } from '@tailor-ui/utils';

import { PopoverContent, PopoverHeader, StyledPopover } from './styles';

Expand Down Expand Up @@ -137,14 +137,14 @@ const Popover: FunctionComponent<PopoverProps> = ({
onKeydown: handleClose,
});

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

Expand All @@ -154,7 +154,9 @@ const Popover: FunctionComponent<PopoverProps> = ({

return cloneElement(children, {
ref,
onClick: toggle,
...mergeEventProps(children.props, {
onClick: toggle,
}),
});
};

Expand Down

0 comments on commit 9de4570

Please sign in to comment.