@vaadin/vaadin-combo-box 5.4.11 → 5.4.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.
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "repository": "vaadin/vaadin-combo-box",
11
11
  "homepage": "https://vaadin.com/components",
12
12
  "name": "@vaadin/vaadin-combo-box",
13
- "version": "5.4.11",
13
+ "version": "5.4.12",
14
14
  "main": "vaadin-combo-box.js",
15
15
  "author": "Vaadin Ltd",
16
16
  "license": "Apache-2.0",
@@ -25,39 +25,40 @@
25
25
  "theme"
26
26
  ],
27
27
  "resolutions": {
28
- "es-abstract": "1.17.6",
29
- "@types/doctrine": "0.0.3",
30
28
  "inherits": "2.0.3",
31
29
  "samsam": "1.1.3",
32
30
  "supports-color": "3.1.2",
33
31
  "type-detect": "1.0.0"
34
32
  },
35
33
  "dependencies": {
36
- "@polymer/iron-a11y-announcer": "^3.0.0",
37
34
  "@polymer/iron-a11y-keys-behavior": "^3.0.0",
35
+ "@polymer/iron-a11y-announcer": "^3.0.0",
38
36
  "@polymer/iron-list": "^3.0.0",
39
37
  "@polymer/iron-resizable-behavior": "^3.0.0",
40
38
  "@polymer/polymer": "^3.0.0",
41
39
  "@vaadin/vaadin-control-state-mixin": "^2.2.2",
42
- "@vaadin/vaadin-element-mixin": "^2.4.1",
43
- "@vaadin/vaadin-item": "^2.3.0",
44
- "@vaadin/vaadin-lumo-styles": "^1.1.1",
45
- "@vaadin/vaadin-material-styles": "^1.1.2",
46
40
  "@vaadin/vaadin-overlay": "^3.5.0",
47
41
  "@vaadin/vaadin-text-field": "^2.8.0",
48
- "@vaadin/vaadin-themable-mixin": "^1.6.1"
42
+ "@vaadin/vaadin-themable-mixin": "^1.6.1",
43
+ "@vaadin/vaadin-lumo-styles": "^1.1.1",
44
+ "@vaadin/vaadin-material-styles": "^1.1.2",
45
+ "@vaadin/vaadin-item": "^2.3.0",
46
+ "@vaadin/vaadin-element-mixin": "^2.4.1"
49
47
  },
50
48
  "scripts": {
51
- "generate-typings": "gen-typescript-declarations --outDir . --verify"
49
+ "generate-typings": "gen-typescript-declarations --outDir . --verify",
50
+ "test": "wct --npm"
52
51
  },
53
52
  "devDependencies": {
54
- "@polymer/iron-component-page": "^4.0.0",
53
+ "@web-padawan/gen-typescript-declarations": "^1.6.2",
54
+ "web-component-tester": "6.9.2",
55
55
  "@polymer/iron-form": "^3.0.0",
56
+ "@polymer/iron-component-page": "^4.0.0",
56
57
  "@polymer/iron-test-helpers": "^3.0.0",
57
58
  "@polymer/paper-input": "^3.0.0",
58
59
  "@vaadin/vaadin-button": "^2.4.0",
60
+ "wct-browser-legacy": "^1.0.1",
59
61
  "@vaadin/vaadin-demo-helpers": "^3.1.0",
60
- "@vaadin/vaadin-dialog": "^2.5.0",
61
- "wct-browser-legacy": "^1.0.1"
62
+ "@vaadin/vaadin-dialog": "^2.5.0"
62
63
  }
63
64
  }
@@ -704,13 +704,19 @@ export const ComboBoxMixin = subclass => class VaadinComboBoxMixinElement extend
704
704
  }
705
705
  } else {
706
706
  const toLowerCase = (item) => item && item.toLowerCase && item.toLowerCase();
707
- const itemsMatchedByLabel = this.filteredItems
708
- && this.filteredItems.filter(item => toLowerCase(this._getItemLabel(item)) === toLowerCase(this._inputElementValue))
709
- || [];
707
+
708
+ // Try to find an item whose label matches the input value. A matching item is searched from
709
+ // the filteredItems array (if available) and the selectedItem (if available).
710
+ const itemMatchingByLabel = [...(this.filteredItems || []), this.selectedItem].filter((item) => {
711
+ return toLowerCase(this._getItemLabel(item)) === toLowerCase(this._inputElementValue);
712
+ })[0];
713
+
710
714
  if (this.allowCustomValue
711
715
  // to prevent a repetitive input value being saved after pressing ESC and Tab.
712
- && !itemsMatchedByLabel.length) {
716
+ && !itemMatchingByLabel) {
713
717
 
718
+ // An item matching by label was not found, but custom values are allowed.
719
+ // Dispatch a custom-value-set event with the input value.
714
720
  const e = new CustomEvent('custom-value-set', {detail: this._inputElementValue, composed: true, cancelable: true, bubbles: true});
715
721
  this.dispatchEvent(e);
716
722
  if (!e.defaultPrevented) {
@@ -718,9 +724,11 @@ export const ComboBoxMixin = subclass => class VaadinComboBoxMixinElement extend
718
724
  this._selectItemForValue(customValue);
719
725
  this.value = customValue;
720
726
  }
721
- } else if (!this.allowCustomValue && !this.opened && itemsMatchedByLabel.length > 0) {
722
- this.value = this._getItemValue(itemsMatchedByLabel[0]);
727
+ } else if (!this.allowCustomValue && !this.opened && itemMatchingByLabel) {
728
+ // An item matching by label was found, select it.
729
+ this.value = this._getItemValue(itemMatchingByLabel);
723
730
  } else {
731
+ // Revert the input value
724
732
  this._inputElementValue = this.selectedItem ? this._getItemLabel(this.selectedItem) : (this.value || '');
725
733
  }
726
734
  }
@@ -229,7 +229,7 @@ class ComboBoxElement extends
229
229
  }
230
230
 
231
231
  static get version() {
232
- return '5.4.11';
232
+ return '5.4.12';
233
233
  }
234
234
 
235
235
  static get properties() {