Skip to content

Commit

Permalink
fix(editor): autocomplete should only save empty when val is null (#1500
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ghiscoding committed May 2, 2024
1 parent bb19008 commit 8de1340
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/common/src/editors/autocompleterEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,18 +554,16 @@ export class AutocompleterEditor<T extends AutocompleteItem = any> 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();
}

// 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);

Expand Down

0 comments on commit 8de1340

Please sign in to comment.