mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 08:16:09 +08:00
fix(composer): whilePreservingSelection
should not call select if not activeElement
This commit is contained in:
parent
67a448db5d
commit
c72e5099aa
|
@ -36,6 +36,10 @@ class EditorAPI
|
|||
currentSelection: -> @_extendedSelection
|
||||
|
||||
whilePreservingSelection: (fn) ->
|
||||
# We only preserve selection if the active element is actually within the
|
||||
# contenteditable. Otherwise, we can unintentionally "steal" focus back if
|
||||
# `whilePreservingSelection` is called by a plugin when we are not focused.
|
||||
return fn() unless document.activeElement is @rootNode or @rootNode.contains(document.activeElement)
|
||||
sel = @currentSelection().exportSelection()
|
||||
fn()
|
||||
@select(sel)
|
||||
|
|
Loading…
Reference in a new issue