@vaadin/combo-box 22.0.4 → 22.0.7
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 -14
- package/src/vaadin-combo-box-dropdown.js +1 -11
- package/src/vaadin-combo-box-mixin.js +25 -11
- package/src/vaadin-combo-box.js +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.7",
|
|
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.7",
|
|
37
|
+
"@vaadin/field-base": "^22.0.7",
|
|
38
|
+
"@vaadin/input-container": "^22.0.7",
|
|
39
|
+
"@vaadin/item": "^22.0.7",
|
|
40
|
+
"@vaadin/vaadin-lumo-styles": "^22.0.7",
|
|
41
|
+
"@vaadin/vaadin-material-styles": "^22.0.7",
|
|
42
|
+
"@vaadin/vaadin-overlay": "^22.0.7",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "^22.0.7"
|
|
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.7",
|
|
48
|
+
"@vaadin/polymer-legacy-adapter": "^22.0.7",
|
|
50
49
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
|
-
"@vaadin/text-field": "^22.0.
|
|
50
|
+
"@vaadin/text-field": "^22.0.7",
|
|
52
51
|
"lit": "^2.0.0",
|
|
53
52
|
"sinon": "^9.2.0"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "947d74491296ca746b360ecb5f5a8efd55ab2866"
|
|
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', {
|
|
@@ -413,6 +413,16 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
/**
|
|
417
|
+
* @param {Event} event
|
|
418
|
+
* @protected
|
|
419
|
+
*/
|
|
420
|
+
_onHostClick(_event) {
|
|
421
|
+
if (!this.autoOpenDisabled) {
|
|
422
|
+
this.open();
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
416
426
|
/** @private */
|
|
417
427
|
_onClick(e) {
|
|
418
428
|
this._closeOnBlurIsPrevented = true;
|
|
@@ -427,8 +437,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
427
437
|
} else {
|
|
428
438
|
this.open();
|
|
429
439
|
}
|
|
430
|
-
} else
|
|
431
|
-
this.
|
|
440
|
+
} else {
|
|
441
|
+
this._onHostClick(e);
|
|
432
442
|
}
|
|
433
443
|
|
|
434
444
|
this._closeOnBlurIsPrevented = false;
|
|
@@ -650,8 +660,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
650
660
|
|
|
651
661
|
/** @private */
|
|
652
662
|
_onOpened() {
|
|
653
|
-
setTimeout(() => this._resizeDropdown(), 1);
|
|
654
|
-
|
|
655
663
|
// Defer scroll position adjustment to improve performance.
|
|
656
664
|
requestAnimationFrame(() => {
|
|
657
665
|
this.$.dropdown.adjustScrollPosition();
|
|
@@ -706,17 +714,21 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
706
714
|
// to prevent a repetitive input value being saved after pressing ESC and Tab.
|
|
707
715
|
!itemMatchingByLabel
|
|
708
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
|
+
|
|
709
722
|
// An item matching by label was not found, but custom values are allowed.
|
|
710
723
|
// Dispatch a custom-value-set event with the input value.
|
|
711
724
|
const e = new CustomEvent('custom-value-set', {
|
|
712
|
-
detail:
|
|
725
|
+
detail: customValue,
|
|
713
726
|
composed: true,
|
|
714
727
|
cancelable: true,
|
|
715
728
|
bubbles: true
|
|
716
729
|
});
|
|
717
730
|
this.dispatchEvent(e);
|
|
718
731
|
if (!e.defaultPrevented) {
|
|
719
|
-
const customValue = this._inputElementValue;
|
|
720
732
|
this._selectItemForValue(customValue);
|
|
721
733
|
this.value = customValue;
|
|
722
734
|
}
|
|
@@ -832,11 +844,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
832
844
|
}
|
|
833
845
|
}
|
|
834
846
|
|
|
835
|
-
/** @private */
|
|
836
|
-
_resizeDropdown() {
|
|
837
|
-
this.$.dropdown.notifyResize();
|
|
838
|
-
}
|
|
839
|
-
|
|
840
847
|
/** @private */
|
|
841
848
|
_selectedItemChanged(selectedItem) {
|
|
842
849
|
if (selectedItem === null || selectedItem === undefined) {
|
|
@@ -1059,6 +1066,13 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1059
1066
|
return;
|
|
1060
1067
|
}
|
|
1061
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
|
+
|
|
1062
1076
|
this._closeOrCommit();
|
|
1063
1077
|
}
|
|
1064
1078
|
}
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -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);
|