mirror of
https://github.com/atom/atom.git
synced 2026-02-06 20:55:33 -05:00
Merge pull request #14175 from atom/mb-fix-pane-focus-on-activation
Always focus active pane item when pane is activated
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user