igniteui-angular 13.0.11 → 13.0.12

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.
@@ -18812,7 +18812,7 @@ class IgxTextSelectionDirective {
18812
18812
  */
18813
18813
  trigger() {
18814
18814
  if (this.selected && this.nativeElement.value.length) {
18815
- requestAnimationFrame(() => this.nativeElement.setSelectionRange(0, this.nativeElement.value.length));
18815
+ this.nativeElement.select();
18816
18816
  }
18817
18817
  }
18818
18818
  }
@@ -34184,6 +34184,7 @@ class IgxComboBaseDirective extends DisplayDensityBase {
34184
34184
  this._data = [];
34185
34185
  this._value = '';
34186
34186
  this._groupKey = '';
34187
+ this._searchValue = '';
34187
34188
  this._filteredData = [];
34188
34189
  this._remoteSelection = {};
34189
34190
  this._valid = IgxComboState.INITIAL;
@@ -34193,7 +34194,6 @@ class IgxComboBaseDirective extends DisplayDensityBase {
34193
34194
  this._onChangeCallback = noop;
34194
34195
  this._type = null;
34195
34196
  this._dataType = '';
34196
- this._searchValue = '';
34197
34197
  this._itemHeight = null;
34198
34198
  this._itemsMaxHeight = null;
34199
34199
  this._groupSortingDirection = SortingDirection.Asc;
@@ -35729,9 +35729,12 @@ class IgxSimpleComboComponent extends IgxComboBaseDirective {
35729
35729
  /** @hidden @internal */
35730
35730
  this.composing = false;
35731
35731
  this._updateInput = true;
35732
+ // stores the last filtered value - move to common?
35733
+ this._internalFilter = '';
35732
35734
  this.findMatch = (element) => {
35733
35735
  const value = this.displayKey ? element[this.displayKey] : element;
35734
- return value.toString().toLowerCase().includes(this.searchValue.trim().toLowerCase());
35736
+ const searchValue = this.searchValue || this.comboInput.value;
35737
+ return !!searchValue && value.toString().toLowerCase().includes(searchValue.trim().toLowerCase());
35735
35738
  };
35736
35739
  this.comboAPI.register(this);
35737
35740
  }
@@ -35745,6 +35748,16 @@ class IgxSimpleComboComponent extends IgxComboBaseDirective {
35745
35748
  this.checkMatch();
35746
35749
  }
35747
35750
  /** @hidden @internal */
35751
+ get searchValue() {
35752
+ return this._searchValue;
35753
+ }
35754
+ set searchValue(val) {
35755
+ this._searchValue = val;
35756
+ }
35757
+ get selectedItem() {
35758
+ return this.selectionService.get(this.id).values().next().value;
35759
+ }
35760
+ /** @hidden @internal */
35748
35761
  onArrowDown(event) {
35749
35762
  if (this.collapsed) {
35750
35763
  event.preventDefault();
@@ -35807,6 +35820,15 @@ class IgxSimpleComboComponent extends IgxComboBaseDirective {
35807
35820
  this.dropdown.navigateItem(index);
35808
35821
  }
35809
35822
  });
35823
+ this.dropdown.opening.pipe(takeUntil(this.destroy$)).subscribe(() => {
35824
+ const filtered = this.filteredData.find(this.findMatch);
35825
+ if (filtered === undefined || filtered === null) {
35826
+ this.filterValue = this.searchValue = this.comboInput.value;
35827
+ return;
35828
+ }
35829
+ this._internalFilter = this.filterValue;
35830
+ this.filterValue = this.searchValue = '';
35831
+ });
35810
35832
  this.dropdown.opened.pipe(takeUntil(this.destroy$)).subscribe(() => {
35811
35833
  if (this.composing) {
35812
35834
  this.comboInput.focus();
@@ -35821,23 +35843,29 @@ class IgxSimpleComboComponent extends IgxComboBaseDirective {
35821
35843
  this._onTouchedCallback();
35822
35844
  }
35823
35845
  });
35846
+ this.dropdown.closed.pipe(takeUntil(this.destroy$)).subscribe(() => {
35847
+ this.filterValue = this._internalFilter = this.comboInput.value;
35848
+ });
35824
35849
  super.ngAfterViewInit();
35825
35850
  }
35826
35851
  /** @hidden @internal */
35827
35852
  handleInputChange(event) {
35828
35853
  if (event !== undefined) {
35829
- this.searchValue = typeof event === 'string' ? event : event.target.value;
35854
+ this.filterValue = this._internalFilter = this.searchValue = typeof event === 'string' ? event : event.target.value;
35830
35855
  }
35831
35856
  this._onChangeCallback(this.searchValue);
35832
35857
  if (this.collapsed && this.comboInput.focused) {
35833
35858
  this.open();
35834
- this.dropdown.navigateFirst();
35835
35859
  }
35836
35860
  if (!this.comboInput.value.trim()) {
35837
35861
  // handle clearing of input by space
35838
35862
  this.clearSelection();
35839
35863
  this._onChangeCallback(null);
35840
35864
  }
35865
+ // when filtering the focused item should be the first item or the currently selected item
35866
+ if (!this.dropdown.focusedItem || this.dropdown.focusedItem.id !== this.dropdown.items[0].id) {
35867
+ this.dropdown.navigateFirst();
35868
+ }
35841
35869
  super.handleInputChange(event);
35842
35870
  this.composing = true;
35843
35871
  }
@@ -35854,15 +35882,15 @@ class IgxSimpleComboComponent extends IgxComboBaseDirective {
35854
35882
  this.close();
35855
35883
  // manually trigger text selection as it will not be triggered during editing
35856
35884
  this.textSelection.trigger();
35885
+ this.filterValue = this.getElementVal(filtered);
35857
35886
  return;
35858
35887
  }
35859
35888
  if (event.key === this.platformUtil.KEYMAP.BACKSPACE
35860
35889
  || event.key === this.platformUtil.KEYMAP.DELETE) {
35861
35890
  this._updateInput = false;
35862
- this.clearSelection();
35891
+ this.clearSelection(true);
35863
35892
  }
35864
35893
  if (!this.collapsed && event.key === this.platformUtil.KEYMAP.TAB) {
35865
- this.close();
35866
35894
  this.clearOnBlur();
35867
35895
  }
35868
35896
  this.composing = false;
@@ -36007,10 +36035,26 @@ class IgxSimpleComboComponent extends IgxComboBaseDirective {
36007
36035
  }
36008
36036
  clearOnBlur() {
36009
36037
  const filtered = this.filteredData.find(this.findMatch);
36010
- if ((filtered === undefined || filtered === null)) {
36038
+ if (filtered === undefined || filtered === null || !this.selectedItem) {
36039
+ this.clearAndClose();
36040
+ return;
36041
+ }
36042
+ if (this.isPartialMatch(filtered) || this.selectedItem !== this._internalFilter) {
36043
+ this.clearAndClose();
36044
+ }
36045
+ }
36046
+ isPartialMatch(filtered) {
36047
+ return !!this._internalFilter && this._internalFilter.length !== this.getElementVal(filtered).length;
36048
+ }
36049
+ getElementVal(element) {
36050
+ return this.displayKey ? element[this.displayKey] : element;
36051
+ }
36052
+ clearAndClose() {
36053
+ this.clearSelection(true);
36054
+ this._internalFilter = '';
36055
+ this.searchValue = '';
36056
+ if (!this.collapsed) {
36011
36057
  this.close();
36012
- this.clearSelection();
36013
- this.searchValue = '';
36014
36058
  }
36015
36059
  }
36016
36060
  }