Skip to content

Commit

Permalink
Update the value with the searched text in the onBlur() event of DsDy…
Browse files Browse the repository at this point in the history
…namicOneBoxComponent 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.
  • Loading branch information
toniprieto committed Feb 23, 2024
1 parent b4a9a0d commit 7253a59
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,13 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
// prevent on blur propagation if typeahed suggestions are showed
event.preventDefault();
event.stopImmediatePropagation();
// set focus on input again, this is to avoid to lose changes when no suggestion is selected
(event.target as HTMLInputElement).focus();
// update the value with the searched text if the user hasn't selected any suggestion
if (!this.model.vocabularyOptions.closed && isNotEmpty(this.inputValue)) {
if (isNotNull(this.inputValue) && this.model.value !== this.inputValue) {
this.dispatchUpdate(this.inputValue);
}
this.inputValue = null;
}
}
}

Expand Down

0 comments on commit 7253a59

Please sign in to comment.