     @setState active: !@state.active
 
 
+  addPortal: =>
+    if @portal? && !@portalAdded
+      @body.appendChild @portal
+      @portalAdded = true
+
+
+  removePortal: =>
+    if @portal? && @portalAdded
+      @body.removeChild @portal
+      @portalAdded = false
+
+
   render: =>
     div
       className: 'play-detail-menu'

        i className: 'fas fa-ellipsis-v'

      if @props.usePortal
        @portal ?= document.createElement('div')
        createPortal @renderMenu(), @portal

      else

        @portal.style.top = "#{Math.floor(top + element$.height() / 2)}px"
        @portal.style.left = "#{Math.floor(left + element$.width())}px"

        @addPortal()

      $(document).on "click.#{@uuid} keydown.#{@uuid}", @hide
      @props.onShow?()
    else
      @removePortal()
      $(document).off "click.#{@uuid} keydown.#{@uuid}"
      @props.onHide?()


  componentWillUnmount: =>
    $(document).off ".#{@uuid}"


