@@ -9,6 +9,7 @@ import TriggerContext, {
99import useDelay from '../hooks/useDelay' ;
1010import useAlign from '../hooks/useAlign' ;
1111import Popup from '../Popup' ;
12+ import { useEvent } from '@rc-component/util' ;
1213
1314export interface UniqueProviderProps {
1415 children : React . ReactNode ;
@@ -36,9 +37,19 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
3637 const hide = ( delay : number ) => {
3738 delayInvoke ( ( ) => {
3839 setOpen ( false ) ;
40+ // 不要立即清空 target, currentNode, options,等动画结束后再清空
3941 } , delay ) ;
4042 } ;
4143
44+ // 动画完成后的回调
45+ const onVisibleChanged = useEvent ( ( visible : boolean ) => {
46+ if ( ! visible ) {
47+ setTarget ( null ) ;
48+ setCurrentNode ( null ) ;
49+ setOptions ( null ) ;
50+ }
51+ } ) ;
52+
4253 // =========================== Align ============================
4354 const [
4455 ready ,
@@ -48,9 +59,9 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
4859 offsetB ,
4960 arrowX ,
5061 arrowY , // scaleX - not used in UniqueProvider
51- // scaleY - not used in UniqueProvider
5262 ,
5363 ,
64+ // scaleY - not used in UniqueProvider
5465 alignInfo ,
5566 onAlign ,
5667 ] = useAlign (
@@ -95,15 +106,16 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
95106 < Popup
96107 ref = { setPopupEle }
97108 portal = { Portal }
98- prefixCls = { options . prefixCls || 'rc-trigger-popup' }
109+ prefixCls = { options . prefixCls }
99110 popup = { currentNode }
100111 className = { options . popupClassName }
101112 style = { options . popupStyle }
102113 target = { target }
103114 open = { open }
104- keepDom = { false }
115+ keepDom = { true }
105116 fresh = { true }
106- onVisibleChanged = { ( ) => { } }
117+ autoDestroy = { false }
118+ onVisibleChanged = { onVisibleChanged }
107119 ready = { ready }
108120 offsetX = { offsetX }
109121 offsetY = { offsetY }
0 commit comments