         @portal.style.top = "#{Math.floor(top + element$.height() / 2)}px"
         @portal.style.left = "#{Math.floor(left + element$.width())}px"
 
-        document.body.appendChild @portal
+        @addPortal()
 
       $(document).on "click.#{@uuid} keydown.#{@uuid}", @hide
       @props.onShow?()
     else
-      document.body.removeChild @portal if @portal?
-      $(document).off ".#{@uuid}"
+      @removePortal()
+      $(document).off "click.#{@uuid} keydown.#{@uuid}"
       @props.onHide?()
 
 
   componentWillUnmount: =>
-    document.body.removeChild @portal if @portal?
     $(document).off ".#{@uuid}"
 
 

    @setState active: !@state.active


  render: =>
    div
      className: 'play-detail-menu'

    @uuid = osu.uuid()
    @menu = createRef()

    @body = document.body
    @portal = document.createElement('div') if props.usePortal
    @portalAdded = false

    @state =
      active: false


  componentDidMount: =>
    $(document).on "turbolinks:before-cache.#{@uuid}", () =>
      @removePortal()


  componentDidUpdate: (_prevProps, prevState) =>
