       @dragEventCounts.set(entry, @dragEventCounts.get(entry) + 1)
 
   onDragLeave: (e) =>
-    if header = e.target.closest('.entry.directory > .header')
+    if entry = e.target.closest('.entry.directory')
       return if @rootDragAndDrop.isDragging(e)
 
       e.stopPropagation()
 
-      entry = header.parentNode
       @dragEventCounts.set(entry, @dragEventCounts.get(entry) - 1)
       if @dragEventCounts.get(entry) is 0 and entry.classList.contains('drag-over')
         entry.classList.remove('drag-over', 'selected')

    @list.classList.contains('multi-select')

  onDragEnter: (e) =>
    if header = e.target.closest('.entry.directory > .header')
      return if @rootDragAndDrop.isDragging(e)

      e.stopPropagation()

      entry = header.parentNode
      @dragEventCounts.set(entry, 0) unless @dragEventCounts.get(entry)
      unless @dragEventCounts.get(entry) isnt 0 or entry.classList.contains('selected')
        entry.classList.add('drag-over', 'selected')

  # Handle entry drop event
  onDrop: (e) ->
    @dragEventCounts = new WeakMap
    if entry = e.target.closest('.entry.directory')
      return if @rootDragAndDrop.isDragging(e)

      e.preventDefault()
      e.stopPropagation()

      newDirectoryPath = entry.querySelector('.name')?.dataset.path
      return false unless newDirectoryPath
