Skip to content

Commit

Permalink
Fix for page being cleared when using copy and paste with selectEditor (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
austinsimpson committed Dec 6, 2022
1 parent 2346655 commit f1cadb3
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -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
Expand All @@ -119,6 +120,7 @@ export class SlickCellExternalCopyManager {
editor.loadValue(item);
retVal = editor.serializeValue();
editor.destroy();
tmpP.remove();
} else {
retVal = item[columnDef.field || ''];
}
Expand All @@ -135,15 +137,17 @@ 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
});
editor.loadValue(item);
editor.applyValue(item, value);
editor.destroy();
tmpDiv.remove();
} else {
item[columnDef.field] = value;
}
Expand Down

0 comments on commit f1cadb3

Please sign in to comment.