Update selected entry when moving to top/bottom

This commit is contained in:
Kevin Sawicki
2013-01-16 09:09:46 -08:00
parent 4a976ec872
commit 60481c58d3
2 changed files with 23 additions and 0 deletions

View File

@@ -445,6 +445,14 @@ describe "TreeView", ->
treeView.trigger 'core:move-to-top'
expect(treeView.scrollTop()).toBe 0
it "selects the root entry", ->
entryCount = treeView.find(".entry").length
_.times entryCount, -> treeView.moveDown()
expect(treeView.root).not.toHaveClass 'selected'
treeView.trigger 'core:move-to-top'
expect(treeView.root).toHaveClass 'selected'
describe "core:move-to-bottom", ->
it "scrolls to the bottom", ->
treeView.height(100)
@@ -456,6 +464,11 @@ describe "TreeView", ->
treeView.trigger 'core:move-to-bottom'
expect(treeView.scrollBottom()).toBe treeView.prop('scrollHeight')
it "selects the last entry", ->
expect(treeView.root).toHaveClass 'selected'
treeView.trigger 'core:move-to-bottom'
expect(treeView.root.find('.entry:last')).toHaveClass 'selected'
describe "core:page-up", ->
it "scrolls up a page", ->
treeView.height(5)

View File

@@ -296,3 +296,13 @@ class TreeView extends ScrollView
@scrollBottom(bottom)
if top < @scrollTop()
@scrollTop(top)
scrollToBottom: ->
super()
@selectEntry(@root.find('.entry:last')) if @root
scrollToTop: ->
super()
@selectEntry(@root) if @root