ahuth / preview-tabs

Sublime-style preview tabs for Atom
MIT License
11 stars 2 forks source link

Update binding to tab drop events if the tabs remove stopping event propagation #8

Closed ahuth closed 9 years ago

ahuth commented 9 years ago

If the tabs package stops stopPropagation on the tabs events, list for the 'drop' event on the pane:

initialize: (@paneView) ->
  @preview = null
  @pane = paneView.model
  @subscriptions =
    paneItemAdded: @pane.onDidAddItem @_onPaneItemAdded
    treeEntryDoubleClicked: new PreviewTabsEventHandler(atom.workspaceView, "dblclick", ".tree-view .file", @_onTreeEntryDoubleClicked)
    onDropped: new PreviewTabsEventHandler(@paneView, "drop", ".tab-bar", @_onTabDropped)

Add a test to the PreviewTabsView spec under 'adding pane items':

describe "when a tab is dropped into the pane", ->
  tabBar = null

  beforeEach ->
    tabBar = $(document.createElement("ul")).addClass("tab-bar")
    pane.prepend(tabBar)

  afterEach ->
    tabBar.remove()

  it "keeps the dropped tab", ->
    pane.addItem(editor)
    expect(previewTabsView.preview).toBeTruthy()
    tabBar.trigger("drop")
    expect(previewTabsView.preview).toBeFalsy()