diff --git a/src/clipboard.js b/src/clipboard.js index 34aef60..ee5fe56 100644 --- a/src/clipboard.js +++ b/src/clipboard.js @@ -86,7 +86,6 @@ class Clipboard extends Emitter { if (trigger) { trigger.focus(); } - document.activeElement.blur(); window.getSelection().removeAllRanges(); }, }); diff --git a/test/clipboard.js b/test/clipboard.js index a35cfdf..8aa1175 100644 --- a/test/clipboard.js +++ b/test/clipboard.js @@ -171,16 +171,16 @@ describe('Clipboard', () => { }); describe('#clearSelection', () => { - it('should remove focus from target and text selection', (done) => { + it('should clear text selection without moving focus', (done) => { let clipboard = new Clipboard('.btn'); clipboard.on('success', (e) => { + e.clearSelection(); + let selectedElem = document.activeElement; let selectedText = window.getSelection().toString(); - e.clearSelection(); - - assert.equal(selectedElem, document.body); + assert.equal(selectedElem, e.trigger); assert.equal(selectedText, ''); done();