From 5bf633c5d7b0e2b4ca98c489c7da906286c2c0c8 Mon Sep 17 00:00:00 2001 From: "Ghislain B." Date: Sat, 16 Nov 2024 01:40:53 -0500 Subject: [PATCH] fix: ExternalCopyManager shouldn't change body scroll pos, fixes #1078 (#1741) --- .../extensions/slickCellExternalCopyManager.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/common/src/extensions/slickCellExternalCopyManager.ts b/packages/common/src/extensions/slickCellExternalCopyManager.ts index 8b2acf7e1..dc136995d 100644 --- a/packages/common/src/extensions/slickCellExternalCopyManager.ts +++ b/packages/common/src/extensions/slickCellExternalCopyManager.ts @@ -215,13 +215,15 @@ export class SlickCellExternalCopyManager { // --------------------- protected createTextBox(innerText: string): HTMLTextAreaElement { - const textAreaElm = createDomElement( - 'textarea', - { - value: innerText, - style: { position: 'absolute', left: '-1000px', top: `${document.body.scrollTop}px`, } - }, - this._bodyElement); + const scrollPos = document.documentElement.scrollTop || document.body.scrollTop; + const textAreaElm = createDomElement('textarea', { + value: innerText, + style: { + position: 'absolute', + opacity: '0', + top: `${scrollPos}px` + } + }, this._bodyElement); textAreaElm.select(); return textAreaElm;