Skip to content

Commit 7253a59

Browse files
committed
Update the value with the searched text in the onBlur() event of DsDynamicOneBoxComponent when the user doesn't select any typeahead suggestion. The previous code attempted to maintain focus on the input field to not lose changes but it wasn't working.
1 parent b4a9a0d commit 7253a59

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,13 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
195195
// prevent on blur propagation if typeahed suggestions are showed
196196
event.preventDefault();
197197
event.stopImmediatePropagation();
198-
// set focus on input again, this is to avoid to lose changes when no suggestion is selected
199-
(event.target as HTMLInputElement).focus();
198+
// update the value with the searched text if the user hasn't selected any suggestion
199+
if (!this.model.vocabularyOptions.closed && isNotEmpty(this.inputValue)) {
200+
if (isNotNull(this.inputValue) && this.model.value !== this.inputValue) {
201+
this.dispatchUpdate(this.inputValue);
202+
}
203+
this.inputValue = null;
204+
}
200205
}
201206
}
202207

0 commit comments

Comments
 (0)