@vaadin/multi-select-combo-box 23.1.1 → 23.1.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/multi-select-combo-box",
3
- "version": "23.1.1",
3
+ "version": "23.1.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -33,18 +33,18 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@polymer/polymer": "^3.0.0",
36
- "@vaadin/combo-box": "^23.1.1",
37
- "@vaadin/component-base": "^23.1.1",
38
- "@vaadin/field-base": "^23.1.1",
39
- "@vaadin/input-container": "^23.1.1",
40
- "@vaadin/vaadin-lumo-styles": "^23.1.1",
41
- "@vaadin/vaadin-material-styles": "^23.1.1",
42
- "@vaadin/vaadin-themable-mixin": "^23.1.1"
36
+ "@vaadin/combo-box": "^23.1.2",
37
+ "@vaadin/component-base": "^23.1.2",
38
+ "@vaadin/field-base": "^23.1.2",
39
+ "@vaadin/input-container": "^23.1.2",
40
+ "@vaadin/vaadin-lumo-styles": "^23.1.2",
41
+ "@vaadin/vaadin-material-styles": "^23.1.2",
42
+ "@vaadin/vaadin-themable-mixin": "^23.1.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@esm-bundle/chai": "^4.3.4",
46
46
  "@vaadin/testing-helpers": "^0.3.2",
47
47
  "sinon": "^13.0.2"
48
48
  },
49
- "gitHead": "390458d6519433a2dd502cef90da48e84573a275"
49
+ "gitHead": "6fb205c6e9a761feadfb779dd5d7af96d3102e56"
50
50
  }
@@ -86,6 +86,15 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
86
86
  value: () => [],
87
87
  },
88
88
 
89
+ /**
90
+ * Last input value entered by the user before value is updated.
91
+ * Used to store `filter` property value before clearing it.
92
+ */
93
+ lastFilter: {
94
+ type: String,
95
+ notify: true,
96
+ },
97
+
89
98
  _target: {
90
99
  type: Object,
91
100
  },
@@ -183,6 +192,18 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
183
192
  super._closeOrCommit();
184
193
  }
185
194
 
195
+ /**
196
+ * @protected
197
+ * @override
198
+ */
199
+ _commitValue() {
200
+ // Store filter value for checking if user input is matching
201
+ // an item which is already selected, to not un-select it.
202
+ this.lastFilter = this.filter;
203
+
204
+ super._commitValue();
205
+ }
206
+
186
207
  /**
187
208
  * Override method inherited from the combo-box
188
209
  * to not update focused item when readonly.
@@ -163,6 +163,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
163
163
  allow-custom-value="[[allowCustomValue]]"
164
164
  data-provider="[[dataProvider]]"
165
165
  filter="{{filter}}"
166
+ last-filter="{{_lastFilter}}"
166
167
  loading="{{loading}}"
167
168
  size="{{size}}"
168
169
  filtered-items="[[filteredItems]]"
@@ -441,6 +442,11 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
441
442
  value: -1,
442
443
  observer: '_focusedChipIndexChanged',
443
444
  },
445
+
446
+ /** @private */
447
+ _lastFilter: {
448
+ type: String,
449
+ },
444
450
  };
445
451
  }
446
452
 
@@ -614,7 +620,10 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
614
620
  * @private
615
621
  */
616
622
  _onFilteredItemsChanged(event) {
617
- this.filteredItems = event.detail.value;
623
+ const { value } = event.detail;
624
+ if (Array.isArray(value) || value == null) {
625
+ this.filteredItems = value;
626
+ }
618
627
  }
619
628
 
620
629
  /** @private */
@@ -753,8 +762,9 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
753
762
  let isSelected = false;
754
763
 
755
764
  if (index !== -1) {
765
+ const lastFilter = this._lastFilter;
756
766
  // Do not unselect when manually typing and committing an already selected item.
757
- if (this.filter.toLowerCase() === itemLabel.toLowerCase()) {
767
+ if (lastFilter && lastFilter.toLowerCase() === itemLabel.toLowerCase()) {
758
768
  this.__clearFilter();
759
769
  return;
760
770
  }