 
     event.dataTransfer.setData 'atom-event', 'true'
 
-    element = closest(event.target, '.sortable')
+    element = @tabForElement(event.target)
     element.classList.add('is-dragging')
     element.destroyTooltip()
 

  onMouseDown: (event) ->
    return unless matches(event.target, ".tab")

    tab = closest(event.target, '.tab')
    if event.which is 3 or (event.which is 1 and event.ctrlKey is true)
      @rightClickedTab?.classList.remove('right-clicked')
      @rightClickedTab = tab

    tab.style.maxWidth = '' for tab in @getTabs()
    return

  tabForElement: (element) ->
    currentElement = element
    while currentElement?
      if tab = @tabsByElement.get(currentElement)
        return tab
      else
        currentElement = currentElement.parentElement

module.exports = document.registerElement("atom-tabs", prototype: TabBarView.prototype, extends: "ul")
