   serialize: ->
     directoryExpansionStates: @root?.serializeEntryExpansionStates()
     selectedPath: @selectedEntry()?.getPath()
-    hasFocus: @is(':focus')
+    hasFocus: @hasFocus()
     attached: @hasParent()
     scrollTop: @scrollTop()
 

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

    @root?.unwatchEntries()

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