Scroll to top when selecting first element

This ensures that the top path is always visible
when the first operation is selected.
This commit is contained in:
Kevin Sawicki
2013-01-04 09:03:46 -08:00
parent a891dec093
commit ef39cc7f2d
2 changed files with 6 additions and 2 deletions

View File

@@ -402,7 +402,8 @@ describe "CommandPanel", ->
expect(previewList.scrollBottom()).toBeCloseTo previewList.prop('scrollHeight'), -1
_.times previewList.getOperations().length, -> previewList.trigger 'core:move-up'
previewList.trigger 'core:move-down'
expect(previewList.scrollTop()).toBe 0
it "wraps around when the list is at the beginning or end", ->
rootView.attachToDom()

View File

@@ -73,7 +73,10 @@ class PreviewList extends ScrollView
@children(".selected").removeClass('selected')
element = @children("li.operation:eq(#{index})")
element.addClass('selected')
@scrollToElement(element)
if index is 0
@scrollToTop()
else
@scrollToElement(element)
@selectedOperationIndex = index
executeSelectedOperation: ->