From f1cadb33d99bcd98bc3c79221fbe55a5b1d72cfd Mon Sep 17 00:00:00 2001 From: Austin Simpson <37905990+austinsimpson@users.noreply.github.com> Date: Tue, 6 Dec 2022 09:55:59 -0800 Subject: [PATCH] Fix for page being cleared when using copy and paste with selectEditor (#836) * ExternalCopyManager will now use a new div element instead of document.body. This fixes an issue with the page being cleared when using copy/paste with the single select editor. * Fixed issue with temporary container being orphaned in the DOM --- .../common/src/extensions/slickCellExternalCopyManager.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/common/src/extensions/slickCellExternalCopyManager.ts b/packages/common/src/extensions/slickCellExternalCopyManager.ts index 7e149652f..bf968e169 100644 --- a/packages/common/src/extensions/slickCellExternalCopyManager.ts +++ b/packages/common/src/extensions/slickCellExternalCopyManager.ts @@ -109,8 +109,9 @@ export class SlickCellExternalCopyManager { // if a custom getter is not defined, we call serializeValue of the editor to serialize if (columnDef) { if (columnDef.editor) { + const tmpP = document.createElement('p'); const editor = new (columnDef as any).editor({ - container: document.createElement('p'), // a dummy container + container: tmpP, // a dummy container column: columnDef, event, position: { top: 0, left: 0 }, // a dummy position required by some editors @@ -119,6 +120,7 @@ export class SlickCellExternalCopyManager { editor.loadValue(item); retVal = editor.serializeValue(); editor.destroy(); + tmpP.remove(); } else { retVal = item[columnDef.field || '']; } @@ -135,8 +137,9 @@ export class SlickCellExternalCopyManager { // if a custom setter is not defined, we call applyValue of the editor to unserialize if (columnDef.editor) { + const tmpDiv = document.createElement('div'); const editor = new (columnDef as any).editor({ - container: document.body, // a dummy container + container: tmpDiv, // a dummy container column: columnDef, position: { top: 0, left: 0 }, // a dummy position required by some editors grid: this._grid @@ -144,6 +147,7 @@ export class SlickCellExternalCopyManager { editor.loadValue(item); editor.applyValue(item, value); editor.destroy(); + tmpDiv.remove(); } else { item[columnDef.field] = value; }