From 8de13402d244cb3aa2fcdb4af62e05b06f6cb27c Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Wed, 1 May 2024 21:30:49 -0400 Subject: [PATCH] fix(editor): autocomplete should only save empty when val is null (#1500) --- packages/common/src/editors/autocompleterEditor.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/common/src/editors/autocompleterEditor.ts b/packages/common/src/editors/autocompleterEditor.ts index 68d08e96e..6ca4f854a 100644 --- a/packages/common/src/editors/autocompleterEditor.ts +++ b/packages/common/src/editors/autocompleterEditor.ts @@ -554,7 +554,7 @@ export class AutocompleterEditor implements Ed } this._bindEventService.bind(this._inputElm, 'focus', () => this._inputElm?.select()); - this._bindEventService.bind(this._inputElm, 'keydown', ((event: KeyboardEvent) => { + this._bindEventService.bind(this._inputElm, 'keydown', ((event: KeyboardEvent & { target: HTMLInputElement; }) => { this._lastInputKeyEvent = event; if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') { event.stopImmediatePropagation(); @@ -562,10 +562,8 @@ export class AutocompleterEditor implements Ed // in case the user wants to save even an empty value, // we need to subscribe to the onKeyDown event for that use case and clear the current value - if (this.columnEditor.alwaysSaveOnEnterKey) { - if (event.key === 'Enter') { - this._currentValue = null; - } + if (event.key === 'Enter' && event.target.value === '' && this.columnEditor.alwaysSaveOnEnterKey) { + this._currentValue = null; } }) as EventListener);