mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Restore focus after select list detaches
Previously if the select list was cancelled with no open editors the mini editor would be given focus before being detached causing nothing to have focus after detach completed. Now the select list tracks the previously focused elements and restores focus to that element at the end of the cancel.
This commit is contained in:
@@ -37,7 +37,6 @@ class GrammarView extends SelectList
|
||||
|
||||
cancelled: ->
|
||||
@miniEditor.setText('')
|
||||
@editor.rootView()?.focus() if @miniEditor.isFocused
|
||||
|
||||
confirmed: (grammar) ->
|
||||
@cancel()
|
||||
@@ -48,5 +47,7 @@ class GrammarView extends SelectList
|
||||
@editor.reloadGrammar()
|
||||
|
||||
attach: ->
|
||||
super
|
||||
|
||||
@editor.rootView()?.append(this)
|
||||
@miniEditor.focus()
|
||||
|
||||
@@ -121,10 +121,21 @@ class SelectList extends View
|
||||
else
|
||||
@cancel()
|
||||
|
||||
attach: ->
|
||||
@storeFocusedElement()
|
||||
|
||||
storeFocusedElement: ->
|
||||
@previouslyFocusedElement = $(':focus')
|
||||
|
||||
restoreFocus: ->
|
||||
@previouslyFocusedElement?.focus()
|
||||
|
||||
cancel: ->
|
||||
@list.empty()
|
||||
@cancelling = true
|
||||
miniEditorFocused = @miniEditor.isFocused
|
||||
@cancelled()
|
||||
@detach()
|
||||
@restoreFocus() if miniEditorFocused
|
||||
@cancelling = false
|
||||
clearTimeout(@scheduleTimeout)
|
||||
|
||||
Reference in New Issue
Block a user