diff --git a/src/core/client/ui/components/Popover/Popover.mdx b/src/core/client/ui/components/Popover/Popover.mdx index 936cc615e..7623a293d 100644 --- a/src/core/client/ui/components/Popover/Popover.mdx +++ b/src/core/client/ui/components/Popover/Popover.mdx @@ -9,15 +9,34 @@ import Button from '../Button' # Popover -`Popover` uses `react-popper` +`Popover` uses `react-popper` that has `Popper.js` behind. ## Basic usage + + This is the body} + > + {({ toggleVisibility, forwardRef }) => ( + + )} + + + +#### Example with `placement=top` ( -
This is the body
+
+ This is the body + +
)} > {({ toggleVisibility, forwardRef }) => ( diff --git a/src/core/client/ui/components/Popover/Popover.tsx b/src/core/client/ui/components/Popover/Popover.tsx index 3564aa7ee..3b30c0b91 100644 --- a/src/core/client/ui/components/Popover/Popover.tsx +++ b/src/core/client/ui/components/Popover/Popover.tsx @@ -1,5 +1,5 @@ import cn from "classnames"; -import React, { CSSProperties } from "react"; +import React, { CSSProperties, isValidElement } from "react"; import { Manager, Popper, Reference, RefHandler } from "react-popper"; import AriaInfo from "../AriaInfo"; import * as styles from "./Popover.css"; @@ -22,7 +22,7 @@ type Placement = | "left-start"; interface InnerProps { - body: (props: RenderProps) => any; + body: (props: RenderProps) => any | React.ReactElement; // body: React.ReactElement | null; children: (props: RenderProps) => any; description?: string; @@ -101,10 +101,12 @@ class Popover extends React.Component { className={cn(styles.root, className)} ref={props.ref} > - {body({ - toggleVisibility: this.toggleVisibility, - forwardRef: props.ref, - })} + {isValidElement(body) + ? body + : body({ + toggleVisibility: this.toggleVisibility, + forwardRef: props.ref, + })} {/* */}