From 90d4a670824eb979fc2813d0d42a5803dacd3739 Mon Sep 17 00:00:00 2001 From: Ghislain Beaulac Date: Tue, 24 Mar 2020 19:54:13 -0400 Subject: [PATCH] fix(editors): make sure appendChild exist before using it to add Editor --- packages/common/src/editors/checkboxEditor.ts | 5 ++++- packages/common/src/editors/floatEditor.ts | 5 ++++- packages/common/src/editors/integerEditor.ts | 5 ++++- packages/common/src/editors/textEditor.ts | 5 ++++- packages/common/src/global-grid-options.ts | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/common/src/editors/checkboxEditor.ts b/packages/common/src/editors/checkboxEditor.ts index bcd07d956..22037c407 100644 --- a/packages/common/src/editors/checkboxEditor.ts +++ b/packages/common/src/editors/checkboxEditor.ts @@ -54,7 +54,10 @@ export class CheckboxEditor implements Editor { this._input.title = title; this._input.type = 'checkbox'; this._input.value = 'true'; - this.args.container.append(this._input); + const cellContainer = this.args?.container; + if (cellContainer && typeof cellContainer.appendChild === 'function') { + cellContainer.appendChild(this._input); + } this.focus(); // make the checkbox editor act like a regular checkbox that commit the value on click diff --git a/packages/common/src/editors/floatEditor.ts b/packages/common/src/editors/floatEditor.ts index 098ae3444..68dffb47b 100644 --- a/packages/common/src/editors/floatEditor.ts +++ b/packages/common/src/editors/floatEditor.ts @@ -63,7 +63,10 @@ export class FloatEditor implements Editor { this._input.placeholder = placeholder; this._input.title = title; this._input.step = this.getInputDecimalSteps(); - this.args.container.append(this._input); + const cellContainer = this.args?.container; + if (cellContainer && typeof cellContainer.appendChild === 'function') { + cellContainer.appendChild(this._input); + } this._input.onkeydown = ((event: KeyboardEvent) => { this._lastInputEvent = event; diff --git a/packages/common/src/editors/integerEditor.ts b/packages/common/src/editors/integerEditor.ts index 0b6034a08..c14d71ac0 100644 --- a/packages/common/src/editors/integerEditor.ts +++ b/packages/common/src/editors/integerEditor.ts @@ -60,7 +60,10 @@ export class IntegerEditor implements Editor { this._input.autocomplete = 'off'; this._input.placeholder = placeholder; this._input.title = title; - this.args.container.append(this._input); + const cellContainer = this.args?.container; + if (cellContainer && typeof cellContainer.appendChild === 'function') { + cellContainer.appendChild(this._input); + } this._input.onkeydown = ((event: KeyboardEvent) => { this._lastInputEvent = event; diff --git a/packages/common/src/editors/textEditor.ts b/packages/common/src/editors/textEditor.ts index dcb85303d..884f973b6 100644 --- a/packages/common/src/editors/textEditor.ts +++ b/packages/common/src/editors/textEditor.ts @@ -60,7 +60,10 @@ export class TextEditor implements Editor { this._input.autocomplete = 'off'; this._input.placeholder = placeholder; this._input.title = title; - this.args.container.append(this._input); + const cellContainer = this.args?.container; + if (cellContainer && typeof cellContainer.appendChild === 'function') { + cellContainer.appendChild(this._input); + } this._input.onkeydown = ((event: KeyboardEvent) => { this._lastInputEvent = event; diff --git a/packages/common/src/global-grid-options.ts b/packages/common/src/global-grid-options.ts index e0879bc85..20fee679f 100644 --- a/packages/common/src/global-grid-options.ts +++ b/packages/common/src/global-grid-options.ts @@ -25,7 +25,7 @@ export const GlobalGridOptions: GridOption = { columnPicker: { fadeSpeed: 0, hideForceFitButton: false, - hideSyncResizeButton: true + hideSyncResizeButton: true, }, cellMenu: { autoAdjustDrop: true,