@vaadin/multi-select-combo-box 23.4.0-alpha2 → 23.4.0-alpha3

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.4.0-alpha2",
3
+ "version": "23.4.0-alpha3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,14 +37,14 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@polymer/polymer": "^3.0.0",
40
- "@vaadin/combo-box": "23.4.0-alpha2",
41
- "@vaadin/component-base": "23.4.0-alpha2",
42
- "@vaadin/field-base": "23.4.0-alpha2",
43
- "@vaadin/input-container": "23.4.0-alpha2",
44
- "@vaadin/lit-renderer": "23.4.0-alpha2",
45
- "@vaadin/vaadin-lumo-styles": "23.4.0-alpha2",
46
- "@vaadin/vaadin-material-styles": "23.4.0-alpha2",
47
- "@vaadin/vaadin-themable-mixin": "23.4.0-alpha2"
40
+ "@vaadin/combo-box": "23.4.0-alpha3",
41
+ "@vaadin/component-base": "23.4.0-alpha3",
42
+ "@vaadin/field-base": "23.4.0-alpha3",
43
+ "@vaadin/input-container": "23.4.0-alpha3",
44
+ "@vaadin/lit-renderer": "23.4.0-alpha3",
45
+ "@vaadin/vaadin-lumo-styles": "23.4.0-alpha3",
46
+ "@vaadin/vaadin-material-styles": "23.4.0-alpha3",
47
+ "@vaadin/vaadin-themable-mixin": "23.4.0-alpha3"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@esm-bundle/chai": "^4.3.4",
@@ -56,5 +56,5 @@
56
56
  "web-types.json",
57
57
  "web-types.lit.json"
58
58
  ],
59
- "gitHead": "3fa9a5d13db6baf0307f863669ab2f3f5114c6a0"
59
+ "gitHead": "2336e451b1971dfb2dc4b601e11d05cafdb91516"
60
60
  }
@@ -71,7 +71,7 @@ class MultiSelectComboBoxChip extends ThemableMixin(PolymerElement) {
71
71
  }
72
72
  </style>
73
73
  <div part="label">[[label]]</div>
74
- <div part="remove-button" role="button" on-click="_onRemoveClick"></div>
74
+ <div part="remove-button" on-click="_onRemoveClick"></div>
75
75
  `;
76
76
  }
77
77
 
@@ -58,6 +58,14 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
58
58
  notify: true,
59
59
  },
60
60
 
61
+ /**
62
+ * When true, filter string isn't cleared after selecting an item.
63
+ */
64
+ keepFilter: {
65
+ type: Boolean,
66
+ value: false,
67
+ },
68
+
61
69
  /**
62
70
  * When set to `true`, "loading" attribute is set
63
71
  * on the host and the overlay element.
@@ -274,6 +282,30 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
274
282
  super._onEscape(event);
275
283
  }
276
284
 
285
+ /**
286
+ * Override from combo-box to ignore requests to clear the filter if the
287
+ * keepFilter option is enabled. Exceptions are when the dropdown is closed,
288
+ * so the filter is still cleared on cancel and focus out.
289
+ * @protected
290
+ * @override
291
+ */
292
+ _clearFilter() {
293
+ if (!this.keepFilter || !this.opened) {
294
+ super._clearFilter();
295
+ }
296
+ }
297
+
298
+ /**
299
+ * Override method from combo-box to always clear the filter when reverting
300
+ * the input value, regardless of the keepFilter option.
301
+ * @override
302
+ * @protected
303
+ */
304
+ _revertInputValueToValue() {
305
+ super._revertInputValueToValue();
306
+ this.filter = '';
307
+ }
308
+
277
309
  /**
278
310
  * @protected
279
311
  * @override
@@ -268,6 +268,12 @@ declare class MultiSelectComboBox<TItem = ComboBoxDefaultItem> extends HTMLEleme
268
268
  */
269
269
  i18n: MultiSelectComboBoxI18n;
270
270
 
271
+ /**
272
+ * When true, filter string isn't cleared after selecting an item.
273
+ * @attr {boolean} keep-filter
274
+ */
275
+ keepFilter: boolean;
276
+
271
277
  /**
272
278
  * True when loading items from the data provider, false otherwise.
273
279
  */
@@ -179,6 +179,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
179
179
  top-group="[[_topGroup]]"
180
180
  opened="{{opened}}"
181
181
  renderer="[[renderer]]"
182
+ keep-filter="[[keepFilter]]"
182
183
  theme$="[[_theme]]"
183
184
  on-combo-box-item-selected="_onComboBoxItemSelected"
184
185
  on-change="_onComboBoxChange"
@@ -346,6 +347,14 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
346
347
  },
347
348
  },
348
349
 
350
+ /**
351
+ * When true, filter string isn't cleared after selecting an item.
352
+ */
353
+ keepFilter: {
354
+ type: Boolean,
355
+ value: false,
356
+ },
357
+
349
358
  /**
350
359
  * True when loading items from the data provider, false otherwise.
351
360
  */
@@ -834,10 +843,27 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
834
843
  return selectedItems.indexOf(item);
835
844
  }
836
845
 
837
- /** @private */
838
- __clearFilter() {
839
- this.filter = '';
840
- this.$.comboBox.clear();
846
+ /**
847
+ * Clear the internal combo box value and filter. Filter will not be cleared
848
+ * when the `keepFilter` option is enabled. Using `force` can enforce clearing
849
+ * the filter.
850
+ * @param {boolean} force overrides the keepFilter option
851
+ * @private
852
+ */
853
+ __clearInternalValue(force = false) {
854
+ if (!this.keepFilter || force) {
855
+ // Clear both combo box value and filter.
856
+ this.filter = '';
857
+ this.$.comboBox.clear();
858
+ } else {
859
+ // Only clear combo box value. This effectively resets _lastCommittedValue
860
+ // which allows toggling the same item multiple times via keyboard.
861
+ this.$.comboBox.clear();
862
+ // Restore input to the filter value. Needed when items are
863
+ // navigated with keyboard, which overrides the input value
864
+ // with the item label.
865
+ this.inputElement.value = this.filter;
866
+ }
841
867
  }
842
868
 
843
869
  /** @private */
@@ -869,7 +895,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
869
895
  const lastFilter = this._lastFilter;
870
896
  // Do not unselect when manually typing and committing an already selected item.
871
897
  if (lastFilter && lastFilter.toLowerCase() === itemLabel.toLowerCase()) {
872
- this.__clearFilter();
898
+ this.__clearInternalValue();
873
899
  return;
874
900
  }
875
901
 
@@ -882,7 +908,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
882
908
  this.__updateSelection(itemsCopy);
883
909
 
884
910
  // Suppress `value-changed` event.
885
- this.__clearFilter();
911
+ this.__clearInternalValue();
886
912
 
887
913
  this.__announceItem(itemLabel, isSelected, itemsCopy.length);
888
914
  }
@@ -1226,7 +1252,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
1226
1252
  // Stop the original event
1227
1253
  event.stopPropagation();
1228
1254
 
1229
- this.__clearFilter();
1255
+ this.__clearInternalValue(true);
1230
1256
 
1231
1257
  this.dispatchEvent(
1232
1258
  new CustomEvent('custom-value-set', {
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/multi-select-combo-box",
4
- "version": "23.4.0-alpha2",
4
+ "version": "23.4.0-alpha3",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -241,6 +241,17 @@
241
241
  ]
242
242
  }
243
243
  },
244
+ {
245
+ "name": "keep-filter",
246
+ "description": "When true, filter string isn't cleared after selecting an item.",
247
+ "value": {
248
+ "type": [
249
+ "boolean",
250
+ "null",
251
+ "undefined"
252
+ ]
253
+ }
254
+ },
244
255
  {
245
256
  "name": "loading",
246
257
  "description": "True when loading items from the data provider, false otherwise.",
@@ -572,6 +583,17 @@
572
583
  ]
573
584
  }
574
585
  },
586
+ {
587
+ "name": "keepFilter",
588
+ "description": "When true, filter string isn't cleared after selecting an item.",
589
+ "value": {
590
+ "type": [
591
+ "boolean",
592
+ "null",
593
+ "undefined"
594
+ ]
595
+ }
596
+ },
575
597
  {
576
598
  "name": "loading",
577
599
  "description": "True when loading items from the data provider, false otherwise.",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/multi-select-combo-box",
4
- "version": "23.4.0-alpha2",
4
+ "version": "23.4.0-alpha3",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -89,6 +89,13 @@
89
89
  "kind": "expression"
90
90
  }
91
91
  },
92
+ {
93
+ "name": "?keepFilter",
94
+ "description": "When true, filter string isn't cleared after selecting an item.",
95
+ "value": {
96
+ "kind": "expression"
97
+ }
98
+ },
92
99
  {
93
100
  "name": "?loading",
94
101
  "description": "True when loading items from the data provider, false otherwise.",