Skip to content

Commit 09c6b4b

Browse files
committed
feat(Popup): add debug logs
1 parent 6aea3f0 commit 09c6b4b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/modules/Popup/Popup.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getElementType,
66
getUnhandledProps,
77
isBrowser,
8+
makeDebugger,
89
META,
910
SUI,
1011
useKeyOnly,
@@ -14,6 +15,8 @@ import Portal from '../../addons/Portal'
1415
import PopupContent from './PopupContent'
1516
import PopupHeader from './PopupHeader'
1617

18+
const debug = makeDebugger('popup')
19+
1720
const _meta = {
1821
name: 'Popup',
1922
type: META.TYPES.MODULE,
@@ -234,13 +237,16 @@ export default class Popup extends Component {
234237
portalProps.closeOnTriggerBlur = true
235238
break
236239

237-
default: // default to hover
240+
case 'hover':
238241
portalProps.openOnTriggerMouseOver = true
239242
portalProps.closeOnTriggerMouseLeave = true
240243
// Taken from SUI: https://git.io/vPmCm
241244
portalProps.mouseLeaveDelay = 70
242245
portalProps.mouseOverDelay = 50
243246
break
247+
248+
default:
249+
break
244250
}
245251

246252
if (hoverable) {
@@ -258,18 +264,21 @@ export default class Popup extends Component {
258264
}
259265

260266
handleClose = (e) => {
267+
debug('handleClose()')
261268
const { onClose } = this.props
262269
if (onClose) onClose(e, this.props)
263270
}
264271

265272
handleOpen = (e) => {
273+
debug('handleOpen()')
266274
this.coords = e.currentTarget.getBoundingClientRect()
267275

268276
const { onOpen } = this.props
269277
if (onOpen) onOpen(e, this.props)
270278
}
271279

272280
handlePortalMount = (e) => {
281+
debug('handlePortalMount()')
273282
if (this.props.hideOnScroll) {
274283
window.addEventListener('scroll', this.hideOnScroll)
275284
}
@@ -279,11 +288,13 @@ export default class Popup extends Component {
279288
}
280289

281290
handlePortalUnmount = (e) => {
291+
debug('handlePortalUnmount()')
282292
const { onUnmount } = this.props
283293
if (onUnmount) onUnmount(e, this.props)
284294
}
285295

286296
popupMounted = (ref) => {
297+
debug('popupMounted()')
287298
this.popupCoords = ref ? ref.getBoundingClientRect() : null
288299
this.setPopupStyle()
289300
}
@@ -333,10 +344,12 @@ export default class Popup extends Component {
333344
</ElementType>
334345
)
335346

347+
const mergedPortalProps = { ...this.getPortalProps(), ...portalProps }
348+
debug('portal props:', mergedPortalProps)
349+
336350
return (
337351
<Portal
338-
{...this.getPortalProps()}
339-
{...portalProps}
352+
{...mergedPortalProps}
340353
trigger={trigger}
341354
onClose={this.handleClose}
342355
onMount={this.handlePortalMount}

0 commit comments

Comments
 (0)