@vaadin/combo-box 23.0.0-alpha4 → 23.0.0-alpha5
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 +13 -13
- package/src/vaadin-combo-box-mixin.js +29 -13
- package/src/vaadin-combo-box-scroller.js +13 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "23.0.0-
|
|
3
|
+
"version": "23.0.0-alpha5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,23 +34,23 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
36
36
|
"@polymer/polymer": "^3.0.0",
|
|
37
|
-
"@vaadin/component-base": "23.0.0-
|
|
38
|
-
"@vaadin/field-base": "23.0.0-
|
|
39
|
-
"@vaadin/input-container": "23.0.0-
|
|
40
|
-
"@vaadin/item": "23.0.0-
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "23.0.0-
|
|
42
|
-
"@vaadin/vaadin-material-styles": "23.0.0-
|
|
43
|
-
"@vaadin/vaadin-overlay": "23.0.0-
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "23.0.0-
|
|
37
|
+
"@vaadin/component-base": "23.0.0-alpha5",
|
|
38
|
+
"@vaadin/field-base": "23.0.0-alpha5",
|
|
39
|
+
"@vaadin/input-container": "23.0.0-alpha5",
|
|
40
|
+
"@vaadin/item": "23.0.0-alpha5",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha5",
|
|
42
|
+
"@vaadin/vaadin-material-styles": "23.0.0-alpha5",
|
|
43
|
+
"@vaadin/vaadin-overlay": "23.0.0-alpha5",
|
|
44
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha5"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@esm-bundle/chai": "^4.3.4",
|
|
48
|
-
"@vaadin/dialog": "23.0.0-
|
|
49
|
-
"@vaadin/polymer-legacy-adapter": "23.0.0-
|
|
48
|
+
"@vaadin/dialog": "23.0.0-alpha5",
|
|
49
|
+
"@vaadin/polymer-legacy-adapter": "23.0.0-alpha5",
|
|
50
50
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
|
-
"@vaadin/text-field": "23.0.0-
|
|
51
|
+
"@vaadin/text-field": "23.0.0-alpha5",
|
|
52
52
|
"lit": "^2.0.0",
|
|
53
53
|
"sinon": "^9.2.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "74f9294964eb8552d96578c14af6ad214f5257bc"
|
|
56
56
|
}
|
|
@@ -313,6 +313,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
this.$.dropdown._scroller.requestContentUpdate();
|
|
317
|
+
|
|
316
318
|
this._getItemElements().forEach((item) => {
|
|
317
319
|
item.requestContentUpdate();
|
|
318
320
|
});
|
|
@@ -414,6 +416,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
414
416
|
_handleClearButtonClick(event) {
|
|
415
417
|
event.preventDefault();
|
|
416
418
|
this._clear();
|
|
419
|
+
|
|
420
|
+
// De-select dropdown item
|
|
421
|
+
if (this.opened) {
|
|
422
|
+
this.requestContentUpdate();
|
|
423
|
+
}
|
|
417
424
|
}
|
|
418
425
|
|
|
419
426
|
/** @private */
|
|
@@ -695,17 +702,20 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
695
702
|
}
|
|
696
703
|
} else {
|
|
697
704
|
const toLowerCase = (item) => item && item.toLowerCase && item.toLowerCase();
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
705
|
+
|
|
706
|
+
// Try to find an item whose label matches the input value. A matching item is searched from
|
|
707
|
+
// the filteredItems array (if available) and the selectedItem (if available).
|
|
708
|
+
const itemMatchingByLabel = [...(this.filteredItems || []), this.selectedItem].find((item) => {
|
|
709
|
+
return toLowerCase(this._getItemLabel(item)) === toLowerCase(this._inputElementValue);
|
|
710
|
+
});
|
|
711
|
+
|
|
704
712
|
if (
|
|
705
713
|
this.allowCustomValue &&
|
|
706
714
|
// to prevent a repetitive input value being saved after pressing ESC and Tab.
|
|
707
|
-
!
|
|
715
|
+
!itemMatchingByLabel
|
|
708
716
|
) {
|
|
717
|
+
// An item matching by label was not found, but custom values are allowed.
|
|
718
|
+
// Dispatch a custom-value-set event with the input value.
|
|
709
719
|
const e = new CustomEvent('custom-value-set', {
|
|
710
720
|
detail: this._inputElementValue,
|
|
711
721
|
composed: true,
|
|
@@ -718,9 +728,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
718
728
|
this._selectItemForValue(customValue);
|
|
719
729
|
this.value = customValue;
|
|
720
730
|
}
|
|
721
|
-
} else if (!this.allowCustomValue && !this.opened &&
|
|
722
|
-
|
|
731
|
+
} else if (!this.allowCustomValue && !this.opened && itemMatchingByLabel) {
|
|
732
|
+
// An item matching by label was found, select it.
|
|
733
|
+
this.value = this._getItemValue(itemMatchingByLabel);
|
|
723
734
|
} else {
|
|
735
|
+
// Revert the input value
|
|
724
736
|
this._inputElementValue = this.selectedItem ? this._getItemLabel(this.selectedItem) : this.value || '';
|
|
725
737
|
}
|
|
726
738
|
}
|
|
@@ -934,10 +946,14 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
934
946
|
if (e.path === 'filteredItems' || e.path === 'filteredItems.splices') {
|
|
935
947
|
this._setOverlayItems(this.filteredItems);
|
|
936
948
|
|
|
937
|
-
this.
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
949
|
+
const filterIndex = this.$.dropdown.indexOfLabel(this.filter);
|
|
950
|
+
if (this.opened) {
|
|
951
|
+
this._focusedIndex = filterIndex;
|
|
952
|
+
} else {
|
|
953
|
+
// Pre-select item matching the filter to focus it later when overlay opens
|
|
954
|
+
const valueIndex = this._indexOfValue(this.value, this.filteredItems);
|
|
955
|
+
this._focusedIndex = filterIndex === -1 ? valueIndex : filterIndex;
|
|
956
|
+
}
|
|
941
957
|
|
|
942
958
|
// see https://github.com/vaadin/web-components/issues/2615
|
|
943
959
|
if (this.selectedItem === null && this._focusedIndex >= 0) {
|
|
@@ -136,8 +136,8 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
__openedChanged(opened) {
|
|
139
|
-
if (
|
|
140
|
-
this.
|
|
139
|
+
if (opened) {
|
|
140
|
+
this.requestContentUpdate();
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -163,6 +163,12 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
requestContentUpdate() {
|
|
167
|
+
if (this.__virtualizer) {
|
|
168
|
+
this.__virtualizer.update();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
166
172
|
scrollIntoView(index) {
|
|
167
173
|
if (!(this.opened && index >= 0)) {
|
|
168
174
|
return;
|
|
@@ -232,29 +238,29 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
232
238
|
this.__virtualizer.flush();
|
|
233
239
|
// Ensure the total count of items is properly announced.
|
|
234
240
|
this.setAttribute('aria-setsize', items.length);
|
|
235
|
-
this.
|
|
241
|
+
this.requestContentUpdate();
|
|
236
242
|
}
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
/** @private */
|
|
240
246
|
__loadingChanged(loading) {
|
|
241
247
|
if (this.__virtualizer && !loading) {
|
|
242
|
-
setTimeout(() => this.
|
|
248
|
+
setTimeout(() => this.requestContentUpdate());
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
251
|
|
|
246
252
|
/** @private */
|
|
247
253
|
__focusedIndexChanged(index) {
|
|
248
254
|
if (this.__virtualizer && index >= 0) {
|
|
249
|
-
this.
|
|
255
|
+
this.requestContentUpdate();
|
|
250
256
|
this.scrollIntoView(index);
|
|
251
257
|
}
|
|
252
258
|
}
|
|
253
259
|
|
|
254
260
|
/** @private */
|
|
255
261
|
__rendererChanged(renderer, oldRenderer) {
|
|
256
|
-
if (
|
|
257
|
-
this.
|
|
262
|
+
if (renderer || oldRenderer) {
|
|
263
|
+
this.requestContentUpdate();
|
|
258
264
|
}
|
|
259
265
|
}
|
|
260
266
|
|