diff --git a/ui/app/components/app/menu-droppo.js b/ui/app/components/app/menu-droppo.js
index fa3196b77..ab149d48c 100644
--- a/ui/app/components/app/menu-droppo.js
+++ b/ui/app/components/app/menu-droppo.js
@@ -1,33 +1,91 @@
+import PropTypes from 'prop-types'
import React, { Component } from 'react'
-import { inherits } from 'util'
import { findDOMNode } from 'react-dom'
import ReactCSSTransitionGroup from 'react-transition-group/CSSTransitionGroup'
-export default MenuDroppoComponent
+export default class MenuDroppoComponent extends Component {
+ static propTypes = {
+ isOpen: PropTypes.bool.isRequired,
+ innerStyle: PropTypes.object,
+ children: PropTypes.node.isRequired,
+ onClickOutside: PropTypes.func.isRequired,
+ containerClassName: PropTypes.string,
+ zIndex: PropTypes.number,
+ style: PropTypes.object.isRequired,
+ useCssTransition: PropTypes.bool,
+ speed: PropTypes.string,
+ }
+ renderPrimary () {
+ const isOpen = this.props.isOpen
+ if (!isOpen) {
+ return null
+ }
-inherits(MenuDroppoComponent, Component)
-function MenuDroppoComponent () {
- Component.call(this)
-}
+ const innerStyle = this.props.innerStyle || {}
-MenuDroppoComponent.prototype.render = function () {
- const { containerClassName = '', style } = this.props
- const speed = this.props.speed || '300ms'
- const useCssTransition = this.props.useCssTransition
- const zIndex = ('zIndex' in this.props) ? this.props.zIndex : 0
+ return (
+
+ {this.props.children}
+
+ )
+ }
- this.manageListeners()
+ manageListeners () {
+ const isOpen = this.props.isOpen
+ const onClickOutside = this.props.onClickOutside
- const baseStyle = Object.assign(
- { position: 'fixed' },
- style,
- { zIndex },
- )
+ if (isOpen) {
+ this.outsideClickHandler = onClickOutside
+ } else if (isOpen) {
+ this.outsideClickHandler = null
+ }
+ }
- return (
-
-
- {
- useCssTransition
- ? (
-
- {this.renderPrimary()}
-
- )
- : this.renderPrimary()
- }
-
- )
-}
-
-MenuDroppoComponent.prototype.renderPrimary = function () {
- const isOpen = this.props.isOpen
- if (!isOpen) {
- return null
- }
-
- const innerStyle = this.props.innerStyle || {}
-
- return (
-
- {this.props.children}
-
- )
-}
-
-MenuDroppoComponent.prototype.manageListeners = function () {
- const isOpen = this.props.isOpen
- const onClickOutside = this.props.onClickOutside
-
- if (isOpen) {
- this.outsideClickHandler = onClickOutside
- } else if (isOpen) {
- this.outsideClickHandler = null
- }
-}
-
-MenuDroppoComponent.prototype.componentDidMount = function () {
- if (this && document.body) {
- this.globalClickHandler = this.globalClickOccurred.bind(this)
- document.body.addEventListener('click', this.globalClickHandler)
- // eslint-disable-next-line react/no-find-dom-node
- const container = findDOMNode(this)
- this.container = container
- }
-}
-
-MenuDroppoComponent.prototype.componentWillUnmount = function () {
- if (this && document.body) {
- document.body.removeEventListener('click', this.globalClickHandler)
- }
-}
-
-MenuDroppoComponent.prototype.globalClickOccurred = function (event) {
- const target = event.target
- // eslint-disable-next-line react/no-find-dom-node
- const container = findDOMNode(this)
-
- if (target !== container &&
- !isDescendant(this.container, event.target) &&
- this.outsideClickHandler) {
- this.outsideClickHandler(event)
+
+ {
+ useCssTransition
+ ? (
+
+ {this.renderPrimary()}
+
+ )
+ : this.renderPrimary()
+ }
+
+ )
}
}