Skip to content

Commit

Permalink
Only restore selection if editor has focus (zenoamaro#312)
Browse files Browse the repository at this point in the history
in `setEditorContents`. Prevents component from stealing focus if content changes when the editor isn't focused
  • Loading branch information
Matt Kunze authored and alexkrolick committed Feb 15, 2018
1 parent 6772165 commit 327cf01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ var QuillMixin = {
*/
setEditorContents: function(editor, value) {
var sel = editor.getSelection();

if (typeof value === 'string') {
editor.clipboard.dangerouslyPasteHTML(value);
} else {
editor.setContents(value);
}

if (sel) this.setEditorSelection(editor, sel);
if (sel && editor.hasFocus()) this.setEditorSelection(editor, sel);
},

setEditorSelection: function(editor, range) {
Expand Down

0 comments on commit 327cf01

Please sign in to comment.