Skip to content

Commit

Permalink
Fixed issue with temporary container being orphaned in the DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
austinsimpson committed Dec 6, 2022
1 parent ca14b6c commit 5636155
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
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.createElement('div'), // 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 5636155

Please sign in to comment.