- Note: you can take complete control over the Popover by using the{' '}
- isOpen
prop. Once you make it true
or{' '}
- false
the hover behavior will be disabled.
-
Status: {isOpen ? 'opened' : 'closed'}
+
Note: you can take complete control over the Popover by using the{' '}
- isOpen
prop. Once you make it true
or{' '}
- false
the hover behavior will be disabled.
+ isOpen
and onClick
props. Once you change{' '}
+ isOpen
to true
or false
, the
+ hover behavior will be disabled.
In combination with onClickOutside
you can close the
diff --git a/src/core/Popover/Popover.tsx b/src/core/Popover/Popover.tsx
index 72115448..712b1121 100644
--- a/src/core/Popover/Popover.tsx
+++ b/src/core/Popover/Popover.tsx
@@ -1,5 +1,5 @@
import React, { CSSProperties } from 'react';
-import Tippy from '@tippyjs/react';
+import Tippy, { TippyProps } from '@tippyjs/react';
import { TippyPlacement } from '../types';
type Props = {
@@ -17,11 +17,17 @@ type Props = {
*/
openOnClick?: boolean;
+ /**
+ * Optional callback that gets triggered when the target is clicked.
+ * Is useful for when wanting to take complete control over the popover.
+ */
+ onClick?: () => void;
+
/**
* Optionally callback that gets triggered when clicked outside the popover.
* Is useful for when wanting to take complete control over the popover.
*/
- onClickOutside?: () => void;
+ onClickOutside?: TippyProps['onClickOutside'];
/**
* Content shown inside the popover.
@@ -88,6 +94,7 @@ export function Popover({
tag = 'span',
className,
isOpen,
+ onClick,
openOnClick,
onClickOutside,
style,
@@ -108,7 +115,13 @@ export function Popover({
maxWidth={maxWidth}
trigger={openOnClick ? 'click' : 'mouseenter focus'}
>
-