File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export default class Popup extends Component {
36
36
zIndexWasSynced = false
37
37
38
38
triggerRef = React . createRef ( )
39
+ elementRef = React . createRef ( )
39
40
40
41
static getDerivedStateFromProps ( props , state ) {
41
42
if ( state . closed || state . disabled ) return { }
@@ -101,6 +102,12 @@ export default class Popup extends Component {
101
102
}
102
103
103
104
hideOnScroll = ( e ) => {
105
+ // Do not hide the popup when scroll comes from inside the popup
106
+ // https://github.com/Semantic-Org/Semantic-UI-React/issues/4305
107
+ if ( _ . isElement ( e . target ) && this . elementRef . current . contains ( e . target ) ) {
108
+ return
109
+ }
110
+
104
111
debug ( 'hideOnScroll()' )
105
112
this . setState ( { closed : true } )
106
113
@@ -179,7 +186,7 @@ export default class Popup extends Component {
179
186
}
180
187
181
188
const innerElement = (
182
- < ElementType { ...contentRestProps } className = { classes } style = { styles } >
189
+ < ElementType { ...contentRestProps } className = { classes } style = { styles } ref = { this . elementRef } >
183
190
{ childrenUtils . isNil ( children ) ? (
184
191
< >
185
192
{ PopupHeader . create ( header , { autoGenerateKey : false } ) }
Original file line number Diff line number Diff line change @@ -162,6 +162,24 @@ describe('Popup', () => {
162
162
onClose . should . have . been . calledOnce ( )
163
163
onClose . should . have . been . calledWithMatch ( { } , { content : 'foo' , onClose, trigger } )
164
164
} )
165
+
166
+ it ( 'not hide on scroll from inside a popup' , ( ) => {
167
+ const onClose = sandbox . spy ( )
168
+ const child = < div data-child />
169
+
170
+ wrapperMount (
171
+ < Popup hideOnScroll onClose = { onClose } trigger = { trigger } >
172
+ { child }
173
+ </ Popup > ,
174
+ )
175
+ wrapper . find ( 'button' ) . simulate ( 'click' )
176
+
177
+ domEvent . scroll ( document . querySelector ( '[data-child]' ) )
178
+ onClose . should . not . have . been . called ( )
179
+
180
+ domEvent . scroll ( window )
181
+ onClose . should . have . been . calledOnce ( )
182
+ } )
165
183
} )
166
184
167
185
describe ( 'hoverable' , ( ) => {
You can’t perform that action at this time.
0 commit comments