mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-12 07:34:52 +08:00
fix(composer): whilePreservingSelection
should not call select if not activeElement
This commit is contained in:
parent
67a448db5d
commit
c72e5099aa
1 changed files with 4 additions and 0 deletions
|
@ -36,6 +36,10 @@ class EditorAPI
|
||||||
currentSelection: -> @_extendedSelection
|
currentSelection: -> @_extendedSelection
|
||||||
|
|
||||||
whilePreservingSelection: (fn) ->
|
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()
|
sel = @currentSelection().exportSelection()
|
||||||
fn()
|
fn()
|
||||||
@select(sel)
|
@select(sel)
|
||||||
|
|
Loading…
Add table
Reference in a new issue