@@ -31,14 +31,27 @@ const builtinPlacements = {
31
31
} ,
32
32
} ;
33
33
34
- function preventDefault ( e ) {
35
- e . preventDefault ( ) ;
36
- }
37
-
38
34
function getPopupContainer ( trigger ) {
39
35
return trigger . parentNode ;
40
36
}
41
37
38
+ const InnerTarget = React . forwardRef ( ( props , ref ) => {
39
+ React . useImperativeHandle ( ref , ( ) => ( { } ) ) ;
40
+
41
+ return (
42
+ < div
43
+ style = { { margin : 20 , display : 'inline-block' , background : 'rgba(255, 0, 0, 0.05)' } }
44
+ tabIndex = { 0 }
45
+ role = "button"
46
+ { ...props }
47
+ >
48
+ < p > This is a example of trigger usage.</ p >
49
+ < p > You can adjust the value above</ p >
50
+ < p > which will also change the behaviour of popup.</ p >
51
+ </ div >
52
+ ) ;
53
+ } ) ;
54
+
42
55
class Test extends React . Component {
43
56
state = {
44
57
mask : false ,
@@ -259,7 +272,7 @@ class Test extends React.Component {
259
272
</ div >
260
273
< div style = { { margin : 120 , position : 'relative' } } >
261
274
< Trigger
262
- getPopupContainer = { undefined && getPopupContainer }
275
+ getPopupContainer = { getPopupContainer }
263
276
popupAlign = { this . getPopupAlign ( ) }
264
277
popupPlacement = { state . placement }
265
278
destroyPopupOnHide = { this . state . destroyPopupOnHide }
@@ -281,15 +294,7 @@ class Test extends React.Component {
281
294
popup = { < div > i am a popup</ div > }
282
295
popupTransitionName = { state . transitionName }
283
296
>
284
- < a
285
- style = { { margin : 20 , display : 'inline-block' , background : 'rgba(255, 0, 0, 0.05)' } }
286
- href = "#"
287
- onClick = { preventDefault }
288
- >
289
- < p > This is a example of trigger usage.</ p >
290
- < p > You can adjust the value above</ p >
291
- < p > which will also change the behaviour of popup.</ p >
292
- </ a >
297
+ < InnerTarget />
293
298
</ Trigger >
294
299
</ div >
295
300
</ div >
0 commit comments