     @on 'tree-view:add', => @add()
     @on 'tree-view:remove', => @removeSelectedEntry()
     @on 'tree-view:directory-modified', =>
-      if @is(':focus')
+      if @hasFocus()
         @selectEntryForPath(@selectedPath) if @selectedPath
       else
         @selectActiveFile()

    @root?.unwatchEntries()

  toggle: ->
    if @is(':focus')
      @detach()
      @rootView.focus()
    else

  detach: ->
    @scrollTopAfterAttach = @scrollTop()
    super

  hasFocus: ->
    @is(':focus')

  entryClicked: (e) ->
    entry = $(e.currentTarget).view()
