Skip to content

Commit fce625f

Browse files
committed
1 parent f7040ba commit fce625f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/clipboard-action.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ class ClipboardAction {
6363
this.fakeElem.style.position = 'absolute';
6464
this.fakeElem.style[ isRTL ? 'right' : 'left' ] = '-9999px';
6565
// Move element to the same position vertically
66-
this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
66+
let yPosition = window.pageYOffset || document.documentElement.scrollTop;
67+
this.fakeElem.addEventListener('focus', window.scrollTo(0, yPosition));
68+
this.fakeElem.style.top = yPosition + 'px';
69+
6770
this.fakeElem.setAttribute('readonly', '');
6871
this.fakeElem.value = this.text;
6972

0 commit comments

Comments
 (0)