@vaadin/combo-box 22.0.3 → 22.0.6
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/combo-box",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,25 +32,24 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
35
|
-
"@polymer/iron-resizable-behavior": "^3.0.0",
|
|
36
35
|
"@polymer/polymer": "^3.0.0",
|
|
37
|
-
"@vaadin/component-base": "^22.0.
|
|
38
|
-
"@vaadin/field-base": "^22.0.
|
|
39
|
-
"@vaadin/input-container": "^22.0.
|
|
40
|
-
"@vaadin/item": "^22.0.
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "^22.0.
|
|
42
|
-
"@vaadin/vaadin-material-styles": "^22.0.
|
|
43
|
-
"@vaadin/vaadin-overlay": "^22.0.
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "^22.0.
|
|
36
|
+
"@vaadin/component-base": "^22.0.6",
|
|
37
|
+
"@vaadin/field-base": "^22.0.6",
|
|
38
|
+
"@vaadin/input-container": "^22.0.6",
|
|
39
|
+
"@vaadin/item": "^22.0.6",
|
|
40
|
+
"@vaadin/vaadin-lumo-styles": "^22.0.6",
|
|
41
|
+
"@vaadin/vaadin-material-styles": "^22.0.6",
|
|
42
|
+
"@vaadin/vaadin-overlay": "^22.0.6",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "^22.0.6"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@esm-bundle/chai": "^4.3.4",
|
|
48
|
-
"@vaadin/dialog": "^22.0.
|
|
49
|
-
"@vaadin/polymer-legacy-adapter": "^22.0.
|
|
47
|
+
"@vaadin/dialog": "^22.0.6",
|
|
48
|
+
"@vaadin/polymer-legacy-adapter": "^22.0.6",
|
|
50
49
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
|
-
"@vaadin/text-field": "^22.0.
|
|
50
|
+
"@vaadin/text-field": "^22.0.6",
|
|
52
51
|
"lit": "^2.0.0",
|
|
53
52
|
"sinon": "^9.2.0"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "18c55872d764e338e0f98e65826cbe895156251a"
|
|
56
55
|
}
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
import './vaadin-combo-box-item.js';
|
|
7
7
|
import './vaadin-combo-box-overlay.js';
|
|
8
8
|
import './vaadin-combo-box-scroller.js';
|
|
9
|
-
import { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
|
|
10
|
-
import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
|
|
11
9
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
12
10
|
|
|
13
11
|
/**
|
|
@@ -16,7 +14,7 @@ import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
|
16
14
|
* @extends HTMLElement
|
|
17
15
|
* @private
|
|
18
16
|
*/
|
|
19
|
-
export class ComboBoxDropdown extends
|
|
17
|
+
export class ComboBoxDropdown extends PolymerElement {
|
|
20
18
|
static get is() {
|
|
21
19
|
return 'vaadin-combo-box-dropdown';
|
|
22
20
|
}
|
|
@@ -171,14 +169,6 @@ export class ComboBoxDropdown extends mixinBehaviors(IronResizableBehavior, Poly
|
|
|
171
169
|
this._overlayOpened = false;
|
|
172
170
|
}
|
|
173
171
|
|
|
174
|
-
notifyResize() {
|
|
175
|
-
super.notifyResize();
|
|
176
|
-
|
|
177
|
-
if (this.positionTarget && this.opened) {
|
|
178
|
-
this._setOverlayWidth();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
172
|
_fireTouchAction(sourceEvent) {
|
|
183
173
|
this.dispatchEvent(
|
|
184
174
|
new CustomEvent('vaadin-overlay-touch-action', {
|
|
@@ -305,6 +305,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
305
305
|
return;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
this.$.dropdown._scroller.requestContentUpdate();
|
|
309
|
+
|
|
308
310
|
this._getItemElements().forEach((item) => {
|
|
309
311
|
item.requestContentUpdate();
|
|
310
312
|
});
|
|
@@ -404,6 +406,21 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
404
406
|
_handleClearButtonClick(event) {
|
|
405
407
|
event.preventDefault();
|
|
406
408
|
this._clear();
|
|
409
|
+
|
|
410
|
+
// De-select dropdown item
|
|
411
|
+
if (this.opened) {
|
|
412
|
+
this.requestContentUpdate();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* @param {Event} event
|
|
418
|
+
* @protected
|
|
419
|
+
*/
|
|
420
|
+
_onHostClick(_event) {
|
|
421
|
+
if (!this.autoOpenDisabled) {
|
|
422
|
+
this.open();
|
|
423
|
+
}
|
|
407
424
|
}
|
|
408
425
|
|
|
409
426
|
/** @private */
|
|
@@ -420,8 +437,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
420
437
|
} else {
|
|
421
438
|
this.open();
|
|
422
439
|
}
|
|
423
|
-
} else
|
|
424
|
-
this.
|
|
440
|
+
} else {
|
|
441
|
+
this._onHostClick(e);
|
|
425
442
|
}
|
|
426
443
|
|
|
427
444
|
this._closeOnBlurIsPrevented = false;
|
|
@@ -643,8 +660,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
643
660
|
|
|
644
661
|
/** @private */
|
|
645
662
|
_onOpened() {
|
|
646
|
-
setTimeout(() => this._resizeDropdown(), 1);
|
|
647
|
-
|
|
648
663
|
// Defer scroll position adjustment to improve performance.
|
|
649
664
|
requestAnimationFrame(() => {
|
|
650
665
|
this.$.dropdown.adjustScrollPosition();
|
|
@@ -687,32 +702,41 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
687
702
|
}
|
|
688
703
|
} else {
|
|
689
704
|
const toLowerCase = (item) => item && item.toLowerCase && item.toLowerCase();
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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
|
+
|
|
696
712
|
if (
|
|
697
713
|
this.allowCustomValue &&
|
|
698
714
|
// to prevent a repetitive input value being saved after pressing ESC and Tab.
|
|
699
|
-
!
|
|
715
|
+
!itemMatchingByLabel
|
|
700
716
|
) {
|
|
717
|
+
const customValue = this._inputElementValue;
|
|
718
|
+
|
|
719
|
+
// Store reference to the last custom value for checking it on focusout.
|
|
720
|
+
this._lastCustomValue = customValue;
|
|
721
|
+
|
|
722
|
+
// An item matching by label was not found, but custom values are allowed.
|
|
723
|
+
// Dispatch a custom-value-set event with the input value.
|
|
701
724
|
const e = new CustomEvent('custom-value-set', {
|
|
702
|
-
detail:
|
|
725
|
+
detail: customValue,
|
|
703
726
|
composed: true,
|
|
704
727
|
cancelable: true,
|
|
705
728
|
bubbles: true
|
|
706
729
|
});
|
|
707
730
|
this.dispatchEvent(e);
|
|
708
731
|
if (!e.defaultPrevented) {
|
|
709
|
-
const customValue = this._inputElementValue;
|
|
710
732
|
this._selectItemForValue(customValue);
|
|
711
733
|
this.value = customValue;
|
|
712
734
|
}
|
|
713
|
-
} else if (!this.allowCustomValue && !this.opened &&
|
|
714
|
-
|
|
735
|
+
} else if (!this.allowCustomValue && !this.opened && itemMatchingByLabel) {
|
|
736
|
+
// An item matching by label was found, select it.
|
|
737
|
+
this.value = this._getItemValue(itemMatchingByLabel);
|
|
715
738
|
} else {
|
|
739
|
+
// Revert the input value
|
|
716
740
|
this._inputElementValue = this.selectedItem ? this._getItemLabel(this.selectedItem) : this.value || '';
|
|
717
741
|
}
|
|
718
742
|
}
|
|
@@ -820,11 +844,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
820
844
|
}
|
|
821
845
|
}
|
|
822
846
|
|
|
823
|
-
/** @private */
|
|
824
|
-
_resizeDropdown() {
|
|
825
|
-
this.$.dropdown.notifyResize();
|
|
826
|
-
}
|
|
827
|
-
|
|
828
847
|
/** @private */
|
|
829
848
|
_selectedItemChanged(selectedItem) {
|
|
830
849
|
if (selectedItem === null || selectedItem === undefined) {
|
|
@@ -1047,6 +1066,13 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1047
1066
|
return;
|
|
1048
1067
|
}
|
|
1049
1068
|
if (!this.readonly && !this._closeOnBlurIsPrevented) {
|
|
1069
|
+
// User's logic in `custom-value-set` event listener might cause input to blur,
|
|
1070
|
+
// which will result in attempting to commit the same custom value once again.
|
|
1071
|
+
if (!this.opened && this.allowCustomValue && this._inputElementValue === this._lastCustomValue) {
|
|
1072
|
+
delete this._lastCustomValue;
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1050
1076
|
this._closeOrCommit();
|
|
1051
1077
|
}
|
|
1052
1078
|
}
|
|
@@ -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;
|
|
@@ -233,29 +239,29 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
233
239
|
this.__virtualizer.flush();
|
|
234
240
|
// Ensure the total count of items is properly announced.
|
|
235
241
|
this.setAttribute('aria-setsize', items.length);
|
|
236
|
-
this.
|
|
242
|
+
this.requestContentUpdate();
|
|
237
243
|
}
|
|
238
244
|
}
|
|
239
245
|
|
|
240
246
|
/** @private */
|
|
241
247
|
__loadingChanged(loading) {
|
|
242
248
|
if (this.__virtualizer && !loading) {
|
|
243
|
-
setTimeout(() => this.
|
|
249
|
+
setTimeout(() => this.requestContentUpdate());
|
|
244
250
|
}
|
|
245
251
|
}
|
|
246
252
|
|
|
247
253
|
/** @private */
|
|
248
254
|
__focusedIndexChanged(index) {
|
|
249
255
|
if (this.__virtualizer && index >= 0) {
|
|
250
|
-
this.
|
|
256
|
+
this.requestContentUpdate();
|
|
251
257
|
this.scrollIntoView(index);
|
|
252
258
|
}
|
|
253
259
|
}
|
|
254
260
|
|
|
255
261
|
/** @private */
|
|
256
262
|
__rendererChanged(renderer, oldRenderer) {
|
|
257
|
-
if (
|
|
258
|
-
this.
|
|
263
|
+
if (renderer || oldRenderer) {
|
|
264
|
+
this.requestContentUpdate();
|
|
259
265
|
}
|
|
260
266
|
}
|
|
261
267
|
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -183,8 +183,8 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
183
183
|
>
|
|
184
184
|
<slot name="prefix" slot="prefix"></slot>
|
|
185
185
|
<slot name="input"></slot>
|
|
186
|
-
<div id="clearButton" part="clear-button" slot="suffix"></div>
|
|
187
|
-
<div id="toggleButton" part="toggle-button" slot="suffix"></div>
|
|
186
|
+
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
187
|
+
<div id="toggleButton" part="toggle-button" slot="suffix" aria-hidden="true"></div>
|
|
188
188
|
</vaadin-input-container>
|
|
189
189
|
|
|
190
190
|
<div part="helper-text">
|
|
@@ -291,6 +291,19 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
291
291
|
|
|
292
292
|
this._handleClearButtonClick(event);
|
|
293
293
|
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @param {Event} event
|
|
297
|
+
* @protected
|
|
298
|
+
*/
|
|
299
|
+
_onHostClick(event) {
|
|
300
|
+
const path = event.composedPath();
|
|
301
|
+
|
|
302
|
+
// Open dropdown only when clicking on the label or input field
|
|
303
|
+
if (path.includes(this._labelNode) || path.includes(this._positionTarget)) {
|
|
304
|
+
super._onHostClick(event);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
294
307
|
}
|
|
295
308
|
|
|
296
309
|
customElements.define(ComboBox.is, ComboBox);
|