@skyux/lookup 14.3.3 → 14.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -710,7 +710,7 @@ class SkyAutocompleteComponent {
710
710
  this.#_inputDirective.blur
711
711
  .pipe(delay(25), takeUntil(this.#inputDirectiveUnsubscribe))
712
712
  .subscribe(() => {
713
- directive.restoreInputTextValueToPreviousState();
713
+ this.#handleInputExit();
714
714
  this.#closeDropdown();
715
715
  this.#cancelCurrentSearch();
716
716
  directive.onTouched();
@@ -930,9 +930,7 @@ class SkyAutocompleteComponent {
930
930
  this.#selectSearchResultById(activeElementId);
931
931
  }
932
932
  else {
933
- if (this.inputDirective) {
934
- this.inputDirective.restoreInputTextValueToPreviousState();
935
- }
933
+ this.#handleInputExit();
936
934
  }
937
935
  this.#closeDropdown();
938
936
  break;
@@ -1075,6 +1073,17 @@ class SkyAutocompleteComponent {
1075
1073
  this.isSearchingAsync = false;
1076
1074
  this.#changeDetector.markForCheck();
1077
1075
  }
1076
+ #handleInputExit() {
1077
+ const inputDirective = this.inputDirective;
1078
+ const hasInputText = !!inputDirective?.inputTextValue.trim();
1079
+ if (!hasInputText && inputDirective?.value?.[this.descriptorProperty]) {
1080
+ inputDirective.value = undefined;
1081
+ this.selectionChange.emit({ selectedItem: undefined });
1082
+ }
1083
+ else if (hasInputText) {
1084
+ inputDirective?.restoreInputTextValueToPreviousState();
1085
+ }
1086
+ }
1078
1087
  #performSearchAndUpdateResults() {
1079
1088
  this.#cancelCurrentSearch();
1080
1089
  this.#currentSearchSub = this.#performSearch().subscribe({
@@ -1103,7 +1112,7 @@ class SkyAutocompleteComponent {
1103
1112
  this.highlightText = this.#getHighlightText(this.searchText);
1104
1113
  this.#removeFocusedClass();
1105
1114
  this.#removeActiveDescendant();
1106
- if (this.searchResults.length > 0) {
1115
+ if (this.searchResults.length > 0 && this.searchText) {
1107
1116
  this.#activeElementIndex = 0;
1108
1117
  }
1109
1118
  else {