Fix click behavior when the event target is a child of the li instead of the li

This commit is contained in:
Nathan Sobo
2012-07-23 20:12:06 -06:00
parent 07cd01571e
commit c493272be1
2 changed files with 7 additions and 5 deletions

View File

@@ -344,8 +344,9 @@ describe "CommandPanel", ->
it "opens a new editor with the operation's buffer and selects the search result", ->
operation = previewList.getOperations()[4]
previewList.find('li:eq(4)').mousedown()
previewList.find('li:eq(4) span').mousedown()
expect(previewList.getSelectedOperation()).toBe operation
editSession = rootView.getActiveEditSession()
expect(editSession.buffer.getPath()).toBe project.resolve(operation.getPath())
expect(editSession.getSelectedBufferRange()).toEqual operation.getBufferRange()

View File

@@ -12,11 +12,11 @@ class PreviewList extends View
initialize: (@rootView) ->
@on 'move-down', => @selectNextOperation()
@on 'move-up', => @selectPreviousOperation()
@on 'command-panel:execute', => @execute()
@on 'command-panel:execute', => @executeSelectedOperation()
@on 'mousedown', 'li', (e) =>
index = $(e.target).data('index')
@execute(@getOperations()[index])
@setSelectedOperationIndex(parseInt($(e.target).closest('li').data('index')))
@executeSelectedOperation()
destroy: ->
@destroyOperations() if @operations
@@ -55,7 +55,8 @@ class PreviewList extends View
@scrollToElement(element)
@selectedOperationIndex = index
execute: (operation = @getSelectedOperation()) ->
executeSelectedOperation: ->
operation = @getSelectedOperation()
editSession = @rootView.open(operation.getPath())
operation.execute(editSession)
false