Skip to content

Commit 1bec292

Browse files
committed
feat(CPopover): add onHide and onShow event
1 parent efa1ee4 commit 1bec292

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/components/popover/CPopover.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ export interface CPopoverProps {
1717
* Offset of the popover relative to its target.
1818
*/
1919
offset?: [number, number]
20+
/**
21+
* Callback fired when the component requests to be hidden.
22+
*/
23+
onHide?: () => void
24+
/**
25+
* Callback fired when the component requests to be shown.
26+
*/
27+
onShow?: () => void
2028
/**
2129
* Title node for your component.
2230
*/
@@ -41,6 +49,8 @@ export const CPopover: FC<CPopoverProps> = ({
4149
children,
4250
placement = 'top',
4351
offset = [0, 8],
52+
onHide,
53+
onShow,
4454
trigger = 'click',
4555
visible,
4656
...rest
@@ -85,6 +95,8 @@ export const CPopover: FC<CPopoverProps> = ({
8595
enter: 0,
8696
exit: 200,
8797
}}
98+
onEnter={onShow}
99+
onExit={onHide}
88100
mountOnEnter
89101
unmountOnExit
90102
>
@@ -126,6 +138,8 @@ CPopover.propTypes = {
126138
children: PropTypes.any,
127139
placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
128140
offset: PropTypes.any, // TODO: find good proptype
141+
onHide: PropTypes.func,
142+
onShow: PropTypes.func,
129143
trigger: triggerPropType,
130144
visible: PropTypes.bool,
131145
}

0 commit comments

Comments
 (0)