diff --git a/src/app/modules/angular-slickgrid/editors/__tests__/autoCompleteEditor.spec.ts b/src/app/modules/angular-slickgrid/editors/__tests__/autoCompleteEditor.spec.ts index 755555770..60e47fe14 100644 --- a/src/app/modules/angular-slickgrid/editors/__tests__/autoCompleteEditor.spec.ts +++ b/src/app/modules/angular-slickgrid/editors/__tests__/autoCompleteEditor.spec.ts @@ -200,6 +200,7 @@ describe('AutoCompleteEditor', () => { const event = new (window.window as any).KeyboardEvent('keydown', { keyCode: KEY_CHAR_A, bubbles: true, cancelable: true }); editor = new AutoCompleteEditor(editorArguments); + editor.setValue('z'); const editorElm = divContainer.querySelector('input.editor-gender'); editorElm.focus(); @@ -362,6 +363,7 @@ describe('AutoCompleteEditor', () => { const spy = jest.spyOn(gridStub.getEditorLock(), 'commitCurrentEdit'); editor = new AutoCompleteEditor(editorArguments); + editor.setValue('a'); editor.save(); expect(spy).toHaveBeenCalled(); @@ -372,6 +374,7 @@ describe('AutoCompleteEditor', () => { const spy = jest.spyOn(editorArguments, 'commitChanges'); editor = new AutoCompleteEditor(editorArguments); + editor.setValue('a'); editor.save(); expect(spy).toHaveBeenCalled(); diff --git a/src/app/modules/angular-slickgrid/editors/__tests__/dualInputEditor.spec.ts b/src/app/modules/angular-slickgrid/editors/__tests__/dualInputEditor.spec.ts index 9671bd9e1..b9dba0390 100644 --- a/src/app/modules/angular-slickgrid/editors/__tests__/dualInputEditor.spec.ts +++ b/src/app/modules/angular-slickgrid/editors/__tests__/dualInputEditor.spec.ts @@ -224,6 +224,7 @@ describe('DualInputEditor', () => { const event = new (window.window as any).KeyboardEvent('keydown', { keyCode: KEY_CHAR_0, bubbles: true, cancelable: true }); editor = new DualInputEditor(editorArguments); + editor.setValues(['9', '9']); const editorElm = divContainer.querySelector('input.editor-range'); editor.focus(); diff --git a/src/app/modules/angular-slickgrid/editors/__tests__/floatEditor.spec.ts b/src/app/modules/angular-slickgrid/editors/__tests__/floatEditor.spec.ts index 8c6523592..141fc4c68 100644 --- a/src/app/modules/angular-slickgrid/editors/__tests__/floatEditor.spec.ts +++ b/src/app/modules/angular-slickgrid/editors/__tests__/floatEditor.spec.ts @@ -178,6 +178,7 @@ describe('FloatEditor', () => { const event = new (window.window as any).KeyboardEvent('keydown', { keyCode: KEY_CHAR_0, bubbles: true, cancelable: true }); editor = new FloatEditor(editorArguments); + editor.setValue(9); const editorElm = divContainer.querySelector('input.editor-price'); editor.focus(); diff --git a/src/app/modules/angular-slickgrid/editors/__tests__/integerEditor.spec.ts b/src/app/modules/angular-slickgrid/editors/__tests__/integerEditor.spec.ts index 90cf7d4e7..065d33347 100644 --- a/src/app/modules/angular-slickgrid/editors/__tests__/integerEditor.spec.ts +++ b/src/app/modules/angular-slickgrid/editors/__tests__/integerEditor.spec.ts @@ -178,6 +178,7 @@ describe('IntegerEditor', () => { const event = new (window.window as any).KeyboardEvent('keydown', { keyCode: KEY_CHAR_0, bubbles: true, cancelable: true }); editor = new IntegerEditor(editorArguments); + editor.setValue(9); const editorElm = divContainer.querySelector('input.editor-price'); editor.focus(); diff --git a/src/app/modules/angular-slickgrid/editors/__tests__/longTextEditor.spec.ts b/src/app/modules/angular-slickgrid/editors/__tests__/longTextEditor.spec.ts index 97b2a8b8e..93d96c5b8 100644 --- a/src/app/modules/angular-slickgrid/editors/__tests__/longTextEditor.spec.ts +++ b/src/app/modules/angular-slickgrid/editors/__tests__/longTextEditor.spec.ts @@ -212,6 +212,7 @@ describe('LongTextEditor', () => { const event = new (window.window as any).KeyboardEvent('keydown', { keyCode: KEY_CHAR_A, bubbles: true, cancelable: true }); editor = new LongTextEditor(editorArguments); + editor.setValue('z'); const editorElm = document.body.querySelector('.editor-title textarea'); editor.focus(); @@ -237,6 +238,7 @@ describe('LongTextEditor', () => { const event = new (window.window as any).KeyboardEvent('keydown', { keyCode: KeyCode.ENTER, bubbles: true, cancelable: true }); editor = new LongTextEditor(editorArguments); + editor.setValue('a'); const editorElm = document.body.querySelector('.editor-title textarea'); editor.focus(); diff --git a/src/app/modules/angular-slickgrid/editors/__tests__/textEditor.spec.ts b/src/app/modules/angular-slickgrid/editors/__tests__/textEditor.spec.ts index dbce52f38..2ce1cc1c4 100644 --- a/src/app/modules/angular-slickgrid/editors/__tests__/textEditor.spec.ts +++ b/src/app/modules/angular-slickgrid/editors/__tests__/textEditor.spec.ts @@ -186,6 +186,7 @@ describe('TextEditor', () => { const event = new (window.window as any).KeyboardEvent('keydown', { keyCode: KEY_CHAR_A, bubbles: true, cancelable: true }); editor = new TextEditor(editorArguments); + editor.setValue('z'); const editorElm = divContainer.querySelector('input.editor-title'); editor.focus(); diff --git a/src/app/modules/angular-slickgrid/editors/autoCompleteEditor.ts b/src/app/modules/angular-slickgrid/editors/autoCompleteEditor.ts index 30b63f208..352c5b007 100644 --- a/src/app/modules/angular-slickgrid/editors/autoCompleteEditor.ts +++ b/src/app/modules/angular-slickgrid/editors/autoCompleteEditor.ts @@ -157,11 +157,12 @@ export class AutoCompleteEditor implements Editor { } isValueChanged(): boolean { - const lastEvent = this._lastInputEvent && this._lastInputEvent.keyCode; - if (this.columnEditor && this.columnEditor.alwaysSaveOnEnterKey && lastEvent === KeyCode.ENTER) { + const elmValue = this._$editorElm.val(); + const lastKeyEvent = this._lastInputEvent && this._lastInputEvent.keyCode; + if (this.columnEditor && this.columnEditor.alwaysSaveOnEnterKey && lastKeyEvent === KeyCode.ENTER) { return true; } - return (!(this._$editorElm.val() === '' && this._defaultTextValue === null)) && (this._$editorElm.val() !== this._defaultTextValue); + return (!(elmValue === '' && (this._defaultTextValue === null || this._defaultTextValue === undefined))) && (elmValue !== this._defaultTextValue); } loadValue(item: any) { diff --git a/src/app/modules/angular-slickgrid/editors/dualInputEditor.ts b/src/app/modules/angular-slickgrid/editors/dualInputEditor.ts index b7af83fb4..ed1d7fafd 100644 --- a/src/app/modules/angular-slickgrid/editors/dualInputEditor.ts +++ b/src/app/modules/angular-slickgrid/editors/dualInputEditor.ts @@ -237,8 +237,8 @@ export class DualInputEditor implements Editor { if ((leftEditorParams && leftEditorParams.alwaysSaveOnEnterKey || rightEditorParams && rightEditorParams.alwaysSaveOnEnterKey) && lastKeyEvent === KeyCode.ENTER) { return true; } - const leftResult = (!(leftElmValue === '' && this.originalLeftValue === null)) && (leftElmValue !== this.originalLeftValue); - const rightResult = (!(rightElmValue === '' && this.originalRightValue === null)) && (rightElmValue !== this.originalRightValue); + const leftResult = (!(leftElmValue === '' && (this.originalLeftValue === null || this.originalLeftValue === undefined))) && (leftElmValue !== this.originalLeftValue); + const rightResult = (!(rightElmValue === '' && (this.originalRightValue === null || this.originalRightValue === undefined))) && (rightElmValue !== this.originalRightValue); return leftResult || rightResult; } diff --git a/src/app/modules/angular-slickgrid/editors/floatEditor.ts b/src/app/modules/angular-slickgrid/editors/floatEditor.ts index c37e233db..9c523ae9d 100644 --- a/src/app/modules/angular-slickgrid/editors/floatEditor.ts +++ b/src/app/modules/angular-slickgrid/editors/floatEditor.ts @@ -130,13 +130,13 @@ export class FloatEditor implements Editor { } } - isValueChanged() { + isValueChanged(): boolean { const elmValue = this._$input.val(); - const lastEvent = this._lastInputEvent && this._lastInputEvent.keyCode; - if (this.columnEditor && this.columnEditor.alwaysSaveOnEnterKey && lastEvent === KeyCode.ENTER) { + const lastKeyEvent = this._lastInputEvent && this._lastInputEvent.keyCode; + if (this.columnEditor && this.columnEditor.alwaysSaveOnEnterKey && lastKeyEvent === KeyCode.ENTER) { return true; } - return (!(elmValue === '' && this.originalValue === null)) && (elmValue !== this.originalValue); + return (!(elmValue === '' && (this.originalValue === null || this.originalValue === undefined))) && (elmValue !== this.originalValue); } loadValue(item: any) { diff --git a/src/app/modules/angular-slickgrid/editors/integerEditor.ts b/src/app/modules/angular-slickgrid/editors/integerEditor.ts index c4898f037..62b79ca9c 100644 --- a/src/app/modules/angular-slickgrid/editors/integerEditor.ts +++ b/src/app/modules/angular-slickgrid/editors/integerEditor.ts @@ -104,13 +104,13 @@ export class IntegerEditor implements Editor { } } - isValueChanged() { + isValueChanged(): boolean { const elmValue = this._$input.val(); - const lastEvent = this._lastInputEvent && this._lastInputEvent.keyCode; - if (this.columnEditor && this.columnEditor.alwaysSaveOnEnterKey && lastEvent === KeyCode.ENTER) { + const lastKeyEvent = this._lastInputEvent && this._lastInputEvent.keyCode; + if (this.columnEditor && this.columnEditor.alwaysSaveOnEnterKey && lastKeyEvent === KeyCode.ENTER) { return true; } - return (!(elmValue === '' && this.originalValue === null)) && (elmValue !== this.originalValue); + return (!(elmValue === '' && (this.originalValue === null || this.originalValue === undefined))) && (elmValue !== this.originalValue); } loadValue(item: any) { diff --git a/src/app/modules/angular-slickgrid/editors/longTextEditor.ts b/src/app/modules/angular-slickgrid/editors/longTextEditor.ts index 043243f46..2cbd67232 100644 --- a/src/app/modules/angular-slickgrid/editors/longTextEditor.ts +++ b/src/app/modules/angular-slickgrid/editors/longTextEditor.ts @@ -159,8 +159,9 @@ export class LongTextEditor implements Editor { } } - isValueChanged() { - return (!(this._$textarea.val() === '' && this.defaultValue === null)) && (this._$textarea.val() !== this.defaultValue); + isValueChanged(): boolean { + const elmValue = this._$textarea.val(); + return (!(elmValue === '' && (this.defaultValue === null || this.defaultValue === undefined))) && (elmValue !== this.defaultValue); } loadValue(item: any) { diff --git a/src/app/modules/angular-slickgrid/editors/textEditor.ts b/src/app/modules/angular-slickgrid/editors/textEditor.ts index 63ef86ced..57ed628ac 100644 --- a/src/app/modules/angular-slickgrid/editors/textEditor.ts +++ b/src/app/modules/angular-slickgrid/editors/textEditor.ts @@ -104,13 +104,13 @@ export class TextEditor implements Editor { } } - isValueChanged() { + isValueChanged(): boolean { const elmValue = this._$input.val(); - const lastEvent = this._lastInputEvent && this._lastInputEvent.keyCode; - if (this.columnEditor && this.columnEditor.alwaysSaveOnEnterKey && lastEvent === KeyCode.ENTER) { + const lastKeyEvent = this._lastInputEvent && this._lastInputEvent.keyCode; + if (this.columnEditor && this.columnEditor.alwaysSaveOnEnterKey && lastKeyEvent === KeyCode.ENTER) { return true; } - return (!(elmValue === '' && this.originalValue === null)) && (elmValue !== this.originalValue); + return (!(elmValue === '' && (this.originalValue === null || this.originalValue === undefined))) && (elmValue !== this.originalValue); } loadValue(item: any) {