@@ -14,6 +14,7 @@ import useTargetState from './useTargetState';
14
14
import { isDOM } from '@rc-component/util/lib/Dom/findDOMNode' ;
15
15
import FloatBg from './FloatBg' ;
16
16
import classNames from 'classnames' ;
17
+ import MotionContent from './MotionContent' ;
17
18
18
19
export interface UniqueProviderProps {
19
20
children : React . ReactNode ;
@@ -41,13 +42,18 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
41
42
} ) ;
42
43
43
44
// ========================== Register ==========================
45
+ const [ popupId , setPopupId ] = React . useState ( 0 ) ;
46
+
44
47
const delayInvoke = useDelay ( ) ;
45
48
46
- const show = ( showOptions : UniqueShowOptions ) => {
49
+ const show = useEvent ( ( showOptions : UniqueShowOptions ) => {
47
50
delayInvoke ( ( ) => {
51
+ if ( showOptions . id !== options ?. id ) {
52
+ setPopupId ( ( i ) => i + 1 ) ;
53
+ }
48
54
trigger ( showOptions ) ;
49
55
} , showOptions . delay ) ;
50
- } ;
56
+ } ) ;
51
57
52
58
const hide = ( delay : number ) => {
53
59
delayInvoke ( ( ) => {
@@ -60,11 +66,6 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
60
66
const onVisibleChanged = useEvent ( ( visible : boolean ) => {
61
67
// Call useTargetState callback to handle animation state
62
68
onTargetVisibleChanged ( visible ) ;
63
- // if (!visible) {
64
- // setTarget(null);
65
- // setCurrentNode(null);
66
- // setOptions(null);
67
- // }
68
69
} ) ;
69
70
70
71
// =========================== Align ============================
@@ -133,7 +134,11 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
133
134
ref = { setPopupRef }
134
135
portal = { Portal }
135
136
prefixCls = { prefixCls }
136
- popup = { options . popup }
137
+ popup = {
138
+ < MotionContent prefixCls = { prefixCls } key = { popupId } >
139
+ { options . popup }
140
+ </ MotionContent >
141
+ }
137
142
className = { classNames (
138
143
options . popupClassName ,
139
144
`${ prefixCls } -unique-controlled` ,
0 commit comments