@@ -20,6 +20,8 @@ type HoverPopupProps = {
2020 anchorRef ?: React . RefObject < HTMLElement > ;
2121 onShowPopup ?: VoidFunction ;
2222 onHidePopup ?: VoidFunction ;
23+ delayOpen ?: number ;
24+ delayClose ?: number ;
2325} & Pick < PopupProps , 'placement' | 'contentClassName' > ;
2426
2527export const HoverPopup = ( {
@@ -32,6 +34,8 @@ export const HoverPopup = ({
3234 onHidePopup,
3335 placement = [ 'top' , 'bottom' ] ,
3436 contentClassName,
37+ delayClose = DEBOUNCE_TIMEOUT ,
38+ delayOpen = DEBOUNCE_TIMEOUT ,
3539} : HoverPopupProps ) => {
3640 const [ isPopupVisible , setIsPopupVisible ] = React . useState ( false ) ;
3741 const anchor = React . useRef < HTMLDivElement > ( null ) ;
@@ -41,8 +45,8 @@ export const HoverPopup = ({
4145 debounce ( ( ) => {
4246 setIsPopupVisible ( true ) ;
4347 onShowPopup ?.( ) ;
44- } , DEBOUNCE_TIMEOUT ) ,
45- [ onShowPopup ] ,
48+ } , delayOpen ) ,
49+ [ onShowPopup , delayOpen ] ,
4650 ) ;
4751
4852 const hidePopup = React . useCallback ( ( ) => {
@@ -51,8 +55,8 @@ export const HoverPopup = ({
5155 } , [ onHidePopup ] ) ;
5256
5357 const debouncedHandleHidePopup = React . useMemo (
54- ( ) => debounce ( hidePopup , DEBOUNCE_TIMEOUT ) ,
55- [ hidePopup ] ,
58+ ( ) => debounce ( hidePopup , delayClose ) ,
59+ [ hidePopup , delayClose ] ,
5660 ) ;
5761
5862 const onMouseEnter = debouncedHandleShowPopup ;
0 commit comments