diff --git a/packages/common/src/editors/__tests__/singleSelectEditor.spec.ts b/packages/common/src/editors/__tests__/singleSelectEditor.spec.ts index f7010d96a..7945f7f45 100644 --- a/packages/common/src/editors/__tests__/singleSelectEditor.spec.ts +++ b/packages/common/src/editors/__tests__/singleSelectEditor.spec.ts @@ -126,6 +126,18 @@ describe('SingleSelectEditor', () => { }); describe('isValueChanged method', () => { + it('should return False if the value is undefined', () => { + editor = new SingleSelectEditor(editorArguments); + const editorBtnElm = divContainer.querySelector('.ms-parent.ms-filter.editor-gender button.ms-choice') as HTMLButtonElement; + const editorListElm = divContainer.querySelectorAll(`[name=editor-gender].ms-drop ul>li input[type=radio]`); + editorBtnElm.click(); + + // we can use property "checked" or dispatch an event + editorListElm[0].checked = false; + + expect(editor.isValueChanged()).toBe(false); + }); + it('should return True after doing a check of an option', () => { editor = new SingleSelectEditor(editorArguments); const editorBtnElm = divContainer.querySelector('.ms-parent.ms-filter.editor-gender button.ms-choice') as HTMLButtonElement; diff --git a/packages/common/src/editors/selectEditor.ts b/packages/common/src/editors/selectEditor.ts index ec2a442b9..4fa106044 100644 --- a/packages/common/src/editors/selectEditor.ts +++ b/packages/common/src/editors/selectEditor.ts @@ -401,7 +401,7 @@ export class SelectEditor implements Editor { } destroy() { - // when autoCommitEdit is enabled, we might end up leave the editor without it being saved, if so do call a save before destroying + // when autoCommitEdit is enabled, we might end up leaving an editor without it being saved, if so do call a save before destroying // this mainly happens doing a blur or focusing on another cell in the grid (it won't come here if we click outside the grid, in the body) if (this.$editorElm && this.hasAutoCommitEdit && this.isValueChanged() && !this._isDisposing && !this.isCompositeEditor) { this._isDisposing = true; // change destroying flag to avoid infinite loop @@ -517,7 +517,7 @@ export class SelectEditor implements Editor { return !isEqual; } const value = Array.isArray(valueSelection) && valueSelection.length > 0 ? valueSelection[0] : undefined; - return value !== this.originalValue; + return value !== undefined && value !== this.originalValue; } isValueTouched(): boolean { diff --git a/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip b/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip index 6ac3e1126..3a61a18b8 100644 Binary files a/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip and b/packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip differ