From 6c1632ad767ad23b2ffe481bcbf458b8e85ca83f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 11 Apr 2017 10:28:28 -0700 Subject: [PATCH 1/2] Always focus active pane item when pane is activated Signed-off-by: Nathan Sobo --- spec/pane-element-spec.coffee | 4 ++++ src/pane-element.coffee | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/pane-element-spec.coffee b/spec/pane-element-spec.coffee index 68b0390b2..e4ffa9346 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 diff --git a/src/pane-element.coffee b/src/pane-element.coffee index a6ffa8cf4..054eb9c7c 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 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 From 81819adbd795e3a493bdfc24304c55802d43a815 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 11 Apr 2017 12:20:50 -0700 Subject: [PATCH 2/2] Fix spurious pane activation when changing focus within a pane --- spec/pane-element-spec.coffee | 18 ++++++++++++++++++ src/pane-element.coffee | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/spec/pane-element-spec.coffee b/spec/pane-element-spec.coffee index e4ffa9346..ff7634734 100644 --- a/spec/pane-element-spec.coffee +++ b/spec/pane-element-spec.coffee @@ -175,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 054eb9c7c..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() unless @isActivating + @model.focus() unless @isActivating or @contains(event.relatedTarget) if event.target is this and view = @getActiveView() view.focus() event.stopPropagation()