5
5
getElementType ,
6
6
getUnhandledProps ,
7
7
isBrowser ,
8
+ makeDebugger ,
8
9
META ,
9
10
SUI ,
10
11
useKeyOnly ,
@@ -14,6 +15,8 @@ import Portal from '../../addons/Portal'
14
15
import PopupContent from './PopupContent'
15
16
import PopupHeader from './PopupHeader'
16
17
18
+ const debug = makeDebugger ( 'popup' )
19
+
17
20
const _meta = {
18
21
name : 'Popup' ,
19
22
type : META . TYPES . MODULE ,
@@ -234,13 +237,16 @@ export default class Popup extends Component {
234
237
portalProps . closeOnTriggerBlur = true
235
238
break
236
239
237
- default : // default to hover
240
+ case ' hover' :
238
241
portalProps . openOnTriggerMouseOver = true
239
242
portalProps . closeOnTriggerMouseLeave = true
240
243
// Taken from SUI: https://git.io/vPmCm
241
244
portalProps . mouseLeaveDelay = 70
242
245
portalProps . mouseOverDelay = 50
243
246
break
247
+
248
+ default :
249
+ break
244
250
}
245
251
246
252
if ( hoverable ) {
@@ -258,18 +264,21 @@ export default class Popup extends Component {
258
264
}
259
265
260
266
handleClose = ( e ) => {
267
+ debug ( 'handleClose()' )
261
268
const { onClose } = this . props
262
269
if ( onClose ) onClose ( e , this . props )
263
270
}
264
271
265
272
handleOpen = ( e ) => {
273
+ debug ( 'handleOpen()' )
266
274
this . coords = e . currentTarget . getBoundingClientRect ( )
267
275
268
276
const { onOpen } = this . props
269
277
if ( onOpen ) onOpen ( e , this . props )
270
278
}
271
279
272
280
handlePortalMount = ( e ) => {
281
+ debug ( 'handlePortalMount()' )
273
282
if ( this . props . hideOnScroll ) {
274
283
window . addEventListener ( 'scroll' , this . hideOnScroll )
275
284
}
@@ -279,11 +288,13 @@ export default class Popup extends Component {
279
288
}
280
289
281
290
handlePortalUnmount = ( e ) => {
291
+ debug ( 'handlePortalUnmount()' )
282
292
const { onUnmount } = this . props
283
293
if ( onUnmount ) onUnmount ( e , this . props )
284
294
}
285
295
286
296
popupMounted = ( ref ) => {
297
+ debug ( 'popupMounted()' )
287
298
this . popupCoords = ref ? ref . getBoundingClientRect ( ) : null
288
299
this . setPopupStyle ( )
289
300
}
@@ -333,10 +344,12 @@ export default class Popup extends Component {
333
344
</ ElementType >
334
345
)
335
346
347
+ const mergedPortalProps = { ...this . getPortalProps ( ) , ...portalProps }
348
+ debug ( 'portal props:' , mergedPortalProps )
349
+
336
350
return (
337
351
< Portal
338
- { ...this . getPortalProps ( ) }
339
- { ...portalProps }
352
+ { ...mergedPortalProps }
340
353
trigger = { trigger }
341
354
onClose = { this . handleClose }
342
355
onMount = { this . handlePortalMount }
0 commit comments