@@ -22,15 +22,21 @@ describe('Trigger.Point', () => {
2222
2323 render ( ) {
2424 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' } }
3129 >
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 >
3440 ) ;
3541 }
3642 }
@@ -120,6 +126,21 @@ describe('Trigger.Point', () => {
120126 done ( ) ;
121127 } ) ( ) ;
122128 } ) ;
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+ } ) ;
123144 } ) ;
124145
125146 describe ( 'placement' , ( ) => {
0 commit comments