mirror of
https://github.com/atom/atom.git
synced 2026-02-12 23:55:10 -05:00
Forward window focus when active element is body
This problem was when the focus element is detached when navigating away from the window and when the window is then given focus again nothing has focus. The solution is to use RootView's focus handler on the window to bring focus to the editor or other view when the document's active element is the body meaning nothing inside the RootView currently has focus.
This commit is contained in:
@@ -55,20 +55,24 @@ class RootView extends View
|
||||
panesViewState: @panes.children().view()?.serialize()
|
||||
extensionStates: @serializeExtensions()
|
||||
|
||||
handleEvents: ->
|
||||
@on 'toggle-dev-tools', => atom.toggleDevTools()
|
||||
@on 'focus', (e) =>
|
||||
if @getActiveEditor()
|
||||
@getActiveEditor().focus()
|
||||
handleFocus: (e) ->
|
||||
if @getActiveEditor()
|
||||
@getActiveEditor().focus()
|
||||
false
|
||||
else
|
||||
@setTitle(null)
|
||||
focusableChild = this.find("[tabindex=-1]:visible:first")
|
||||
if focusableChild.length
|
||||
focusableChild.focus()
|
||||
false
|
||||
else
|
||||
@setTitle(null)
|
||||
focusableChild = this.find("[tabindex=-1]:visible:first")
|
||||
if focusableChild.length
|
||||
focusableChild.focus()
|
||||
false
|
||||
else
|
||||
true
|
||||
true
|
||||
|
||||
handleEvents: ->
|
||||
@on 'toggle-dev-tools', => atom.toggleDevTools()
|
||||
@on 'focus', (e) => @handleFocus(e)
|
||||
$(window).on 'focus', (e) =>
|
||||
@handleFocus(e) if document.activeElement is document.body
|
||||
|
||||
@on 'active-editor-path-change', (e, path) =>
|
||||
@project.setPath(path) unless @project.getRootDirectory()
|
||||
|
||||
Reference in New Issue
Block a user