From fce625f1515fea353072e4253ead96335e681b18 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Sun, 16 Oct 2016 18:53:34 -0700 Subject: [PATCH] Fixes #320 --- src/clipboard-action.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/clipboard-action.js b/src/clipboard-action.js index 074aad8..6670254 100644 --- a/src/clipboard-action.js +++ b/src/clipboard-action.js @@ -63,7 +63,10 @@ class ClipboardAction { this.fakeElem.style.position = 'absolute'; this.fakeElem.style[ isRTL ? 'right' : 'left' ] = '-9999px'; // Move element to the same position vertically - this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px'; + let yPosition = window.pageYOffset || document.documentElement.scrollTop; + this.fakeElem.addEventListener('focus', window.scrollTo(0, yPosition)); + this.fakeElem.style.top = yPosition + 'px'; + this.fakeElem.setAttribute('readonly', ''); this.fakeElem.value = this.text;