@@ -22,15 +22,21 @@ describe('Trigger.Point', () => {
22
22
23
23
render ( ) {
24
24
return (
25
- < Trigger
26
- ref = { this . props . triggerRef }
27
- popup = { this . popup }
28
- popupAlign = { { points : [ 'tl' ] } }
29
- alignPoint
30
- { ...this . props }
25
+ < div
26
+ className = "scroll"
27
+ // Jest can not get calculated style in jsdom. So we need to set it manually
28
+ style = { { overflowX : 'hidden' , overflowY : 'hidden' } }
31
29
>
32
- < div className = "point-region" />
33
- </ Trigger >
30
+ < Trigger
31
+ ref = { this . props . triggerRef }
32
+ popup = { this . popup }
33
+ popupAlign = { { points : [ 'tl' ] } }
34
+ alignPoint
35
+ { ...this . props }
36
+ >
37
+ < div className = "point-region" />
38
+ </ Trigger >
39
+ </ div >
34
40
) ;
35
41
}
36
42
}
@@ -120,6 +126,21 @@ describe('Trigger.Point', () => {
120
126
done ( ) ;
121
127
} ) ( ) ;
122
128
} ) ;
129
+
130
+ it ( 'should hide popup when set alignPoint after scrolling' , async ( ) => {
131
+ const { container } = render ( < Demo action = { [ 'contextMenu' ] } /> ) ;
132
+ await trigger ( container , 'contextmenu' , { clientX : 10 , clientY : 20 } ) ;
133
+
134
+ const popup = document . querySelector ( '.rc-trigger-popup' ) ;
135
+ expect ( popup . style ) . toEqual (
136
+ expect . objectContaining ( { left : '10px' , top : '20px' } ) ,
137
+ ) ;
138
+
139
+ const scrollDiv = container . querySelector ( '.scroll' ) ;
140
+ fireEvent . scroll ( scrollDiv ) ;
141
+
142
+ expect ( document . querySelector ( '.rc-trigger-popup-hidden' ) ) . toBeTruthy ( ) ;
143
+ } ) ;
123
144
} ) ;
124
145
125
146
describe ( 'placement' , ( ) => {
0 commit comments