mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Focus root view if previously focused element is no longer attached
This can be the case when a select list is triggered while a different select list is already open and so the second list to open has no element to restore focus to when it closes.
This commit is contained in:
@@ -151,7 +151,10 @@ class SelectList extends View
|
||||
@previouslyFocusedElement = $(':focus')
|
||||
|
||||
restoreFocus: ->
|
||||
@previouslyFocusedElement?.focus()
|
||||
if @previouslyFocusedElement?.isOnDom()
|
||||
@previouslyFocusedElement.focus()
|
||||
else
|
||||
rootView.focus()
|
||||
|
||||
cancelled: ->
|
||||
@miniEditor.setText('')
|
||||
|
||||
@@ -36,6 +36,11 @@ class GoToLineView extends View
|
||||
@detaching = true
|
||||
@miniEditor.setText('')
|
||||
|
||||
if @previouslyFocusedElement?.isOnDom()
|
||||
@previouslyFocusedElement.focus()
|
||||
else
|
||||
rootView.focus()
|
||||
|
||||
super
|
||||
|
||||
@detaching = false
|
||||
|
||||
Reference in New Issue
Block a user