igniteui-angular 12.3.11 → 12.3.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.
@@ -26881,9 +26881,8 @@
26881
26881
  * ```
26882
26882
  */
26883
26883
  IgxTextSelectionDirective.prototype.trigger = function () {
26884
- var _this = this;
26885
26884
  if (this.selected && this.nativeElement.value.length) {
26886
- requestAnimationFrame(function () { return _this.nativeElement.setSelectionRange(0, _this.nativeElement.value.length); });
26885
+ this.nativeElement.select();
26887
26886
  }
26888
26887
  };
26889
26888
  return IgxTextSelectionDirective;
@@ -39503,6 +39502,7 @@
39503
39502
  _this._data = [];
39504
39503
  _this._value = '';
39505
39504
  _this._groupKey = '';
39505
+ _this._searchValue = '';
39506
39506
  _this._filteredData = [];
39507
39507
  _this._remoteSelection = {};
39508
39508
  _this._valid = IgxComboState.INITIAL;
@@ -39512,7 +39512,6 @@
39512
39512
  _this._onChangeCallback = rxjs.noop;
39513
39513
  _this._type = null;
39514
39514
  _this._dataType = '';
39515
- _this._searchValue = '';
39516
39515
  _this._itemHeight = null;
39517
39516
  _this._itemsMaxHeight = null;
39518
39517
  _this.onStatusChanged = function () {
@@ -41051,9 +41050,12 @@
41051
41050
  /** @hidden @internal */
41052
41051
  _this.composing = false;
41053
41052
  _this._updateInput = true;
41053
+ // stores the last filtered value - move to common?
41054
+ _this._internalFilter = '';
41054
41055
  _this.findMatch = function (element) {
41055
41056
  var value = _this.displayKey ? element[_this.displayKey] : element;
41056
- return value.toString().toLowerCase().includes(_this.searchValue.trim().toLowerCase());
41057
+ var searchValue = _this.searchValue || _this.comboInput.value;
41058
+ return !!searchValue && value.toString().toLowerCase().includes(searchValue.trim().toLowerCase());
41057
41059
  };
41058
41060
  _this.comboAPI.register(_this);
41059
41061
  return _this;
@@ -41071,6 +41073,24 @@
41071
41073
  enumerable: false,
41072
41074
  configurable: true
41073
41075
  });
41076
+ Object.defineProperty(IgxSimpleComboComponent.prototype, "searchValue", {
41077
+ /** @hidden @internal */
41078
+ get: function () {
41079
+ return this._searchValue;
41080
+ },
41081
+ set: function (val) {
41082
+ this._searchValue = val;
41083
+ },
41084
+ enumerable: false,
41085
+ configurable: true
41086
+ });
41087
+ Object.defineProperty(IgxSimpleComboComponent.prototype, "selectedItem", {
41088
+ get: function () {
41089
+ return this.selectionService.get(this.id).values().next().value;
41090
+ },
41091
+ enumerable: false,
41092
+ configurable: true
41093
+ });
41074
41094
  /** @hidden @internal */
41075
41095
  IgxSimpleComboComponent.prototype.onArrowDown = function (event) {
41076
41096
  if (this.collapsed) {
@@ -41135,6 +41155,15 @@
41135
41155
  _this.dropdown.navigateItem(index);
41136
41156
  }
41137
41157
  });
41158
+ this.dropdown.opening.pipe(operators.takeUntil(this.destroy$)).subscribe(function () {
41159
+ var filtered = _this.filteredData.find(_this.findMatch);
41160
+ if (filtered === undefined || filtered === null) {
41161
+ _this.filterValue = _this.searchValue = _this.comboInput.value;
41162
+ return;
41163
+ }
41164
+ _this._internalFilter = _this.filterValue;
41165
+ _this.filterValue = _this.searchValue = '';
41166
+ });
41138
41167
  this.dropdown.opened.pipe(operators.takeUntil(this.destroy$)).subscribe(function () {
41139
41168
  if (_this.composing) {
41140
41169
  _this.comboInput.focus();
@@ -41149,23 +41178,29 @@
41149
41178
  _this._onTouchedCallback();
41150
41179
  }
41151
41180
  });
41181
+ this.dropdown.closed.pipe(operators.takeUntil(this.destroy$)).subscribe(function () {
41182
+ _this.filterValue = _this._internalFilter = _this.comboInput.value;
41183
+ });
41152
41184
  _super.prototype.ngAfterViewInit.call(this);
41153
41185
  };
41154
41186
  /** @hidden @internal */
41155
41187
  IgxSimpleComboComponent.prototype.handleInputChange = function (event) {
41156
41188
  if (event !== undefined) {
41157
- this.searchValue = typeof event === 'string' ? event : event.target.value;
41189
+ this.filterValue = this._internalFilter = this.searchValue = typeof event === 'string' ? event : event.target.value;
41158
41190
  }
41159
41191
  this._onChangeCallback(this.searchValue);
41160
41192
  if (this.collapsed && this.comboInput.focused) {
41161
41193
  this.open();
41162
- this.dropdown.navigateFirst();
41163
41194
  }
41164
41195
  if (!this.comboInput.value.trim()) {
41165
41196
  // handle clearing of input by space
41166
41197
  this.clearSelection();
41167
41198
  this._onChangeCallback(null);
41168
41199
  }
41200
+ // when filtering the focused item should be the first item or the currently selected item
41201
+ if (!this.dropdown.focusedItem || this.dropdown.focusedItem.id !== this.dropdown.items[0].id) {
41202
+ this.dropdown.navigateFirst();
41203
+ }
41169
41204
  _super.prototype.handleInputChange.call(this, event);
41170
41205
  this.composing = true;
41171
41206
  };
@@ -41182,15 +41217,15 @@
41182
41217
  this.close();
41183
41218
  // manually trigger text selection as it will not be triggered during editing
41184
41219
  this.textSelection.trigger();
41220
+ this.filterValue = this.getElementVal(filtered);
41185
41221
  return;
41186
41222
  }
41187
41223
  if (event.key === this.platformUtil.KEYMAP.BACKSPACE
41188
41224
  || event.key === this.platformUtil.KEYMAP.DELETE) {
41189
41225
  this._updateInput = false;
41190
- this.clearSelection();
41226
+ this.clearSelection(true);
41191
41227
  }
41192
41228
  if (!this.collapsed && event.key === this.platformUtil.KEYMAP.TAB) {
41193
- this.close();
41194
41229
  this.clearOnBlur();
41195
41230
  }
41196
41231
  this.composing = false;
@@ -41336,10 +41371,26 @@
41336
41371
  };
41337
41372
  IgxSimpleComboComponent.prototype.clearOnBlur = function () {
41338
41373
  var filtered = this.filteredData.find(this.findMatch);
41339
- if ((filtered === undefined || filtered === null)) {
41374
+ if (filtered === undefined || filtered === null || !this.selectedItem) {
41375
+ this.clearAndClose();
41376
+ return;
41377
+ }
41378
+ if (this.isPartialMatch(filtered) || this.selectedItem !== this._internalFilter) {
41379
+ this.clearAndClose();
41380
+ }
41381
+ };
41382
+ IgxSimpleComboComponent.prototype.isPartialMatch = function (filtered) {
41383
+ return !!this._internalFilter && this._internalFilter.length !== this.getElementVal(filtered).length;
41384
+ };
41385
+ IgxSimpleComboComponent.prototype.getElementVal = function (element) {
41386
+ return this.displayKey ? element[this.displayKey] : element;
41387
+ };
41388
+ IgxSimpleComboComponent.prototype.clearAndClose = function () {
41389
+ this.clearSelection(true);
41390
+ this._internalFilter = '';
41391
+ this.searchValue = '';
41392
+ if (!this.collapsed) {
41340
41393
  this.close();
41341
- this.clearSelection();
41342
- this.searchValue = '';
41343
41394
  }
41344
41395
  };
41345
41396
  return IgxSimpleComboComponent;