diff --git a/spec/pane-element-spec.coffee b/spec/pane-element-spec.coffee index 68b0390b2..ff7634734 100644 --- a/spec/pane-element-spec.coffee +++ b/spec/pane-element-spec.coffee @@ -162,6 +162,10 @@ describe "PaneElement", -> paneElement.focus() expect(document.activeElement).toBe item + document.body.focus() + pane.activate() + expect(document.activeElement).toBe item + it "makes the pane active", -> pane.splitRight() expect(pane.isActive()).toBe false @@ -171,6 +175,24 @@ describe "PaneElement", -> expect(pane.isActive()).toBe true + it "does not re-activate the pane when focus changes within the pane", -> + item = document.createElement('div') + itemChild = document.createElement('div') + item.tabIndex = -1 + itemChild.tabIndex = -1 + item.appendChild(itemChild) + jasmine.attachToDOM(paneElement) + + pane.activateItem(item) + pane.activate() + + activationCount = 0 + pane.onDidActivate -> + activationCount++ + + itemChild.focus() + expect(activationCount).toBe(0) + describe "when the pane element is attached", -> it "focuses the pane element if isFocused() returns true on its model", -> pane.focus() diff --git a/src/pane-element.coffee b/src/pane-element.coffee index a6ffa8cf4..2b8260db6 100644 --- a/src/pane-element.coffee +++ b/src/pane-element.coffee @@ -27,7 +27,7 @@ class PaneElement extends HTMLElement subscribeToDOMEvents: -> handleFocus = (event) => - @model.focus() + @model.focus() unless @isActivating or @contains(event.relatedTarget) if event.target is this and view = @getActiveView() view.focus() event.stopPropagation() @@ -66,7 +66,9 @@ class PaneElement extends HTMLElement getModel: -> @model activated: -> - @focus() unless @hasFocus() + @isActivating = true + @focus() + @isActivating = false activeStatusChanged: (active) -> if active