@vaadin/combo-box 23.1.0-rc2 → 23.1.1
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": "23.1.
|
|
3
|
+
"version": "23.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,23 +36,23 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
38
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/component-base": "23.1.
|
|
40
|
-
"@vaadin/field-base": "23.1.
|
|
41
|
-
"@vaadin/input-container": "23.1.
|
|
42
|
-
"@vaadin/item": "23.1.
|
|
43
|
-
"@vaadin/lit-renderer": "23.1.
|
|
44
|
-
"@vaadin/vaadin-lumo-styles": "23.1.
|
|
45
|
-
"@vaadin/vaadin-material-styles": "23.1.
|
|
46
|
-
"@vaadin/vaadin-overlay": "23.1.
|
|
47
|
-
"@vaadin/vaadin-themable-mixin": "23.1.
|
|
39
|
+
"@vaadin/component-base": "^23.1.1",
|
|
40
|
+
"@vaadin/field-base": "^23.1.1",
|
|
41
|
+
"@vaadin/input-container": "^23.1.1",
|
|
42
|
+
"@vaadin/item": "^23.1.1",
|
|
43
|
+
"@vaadin/lit-renderer": "^23.1.1",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "^23.1.1",
|
|
45
|
+
"@vaadin/vaadin-material-styles": "^23.1.1",
|
|
46
|
+
"@vaadin/vaadin-overlay": "^23.1.1",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "^23.1.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@esm-bundle/chai": "^4.3.4",
|
|
51
|
-
"@vaadin/polymer-legacy-adapter": "23.1.
|
|
51
|
+
"@vaadin/polymer-legacy-adapter": "^23.1.1",
|
|
52
52
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
53
|
-
"@vaadin/text-field": "23.1.
|
|
53
|
+
"@vaadin/text-field": "^23.1.1",
|
|
54
54
|
"lit": "^2.0.0",
|
|
55
55
|
"sinon": "^13.0.2"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "390458d6519433a2dd502cef90da48e84573a275"
|
|
58
58
|
}
|
|
@@ -48,7 +48,6 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
48
48
|
*/
|
|
49
49
|
positionTarget: {
|
|
50
50
|
type: Object,
|
|
51
|
-
observer: '_positionTargetChanged',
|
|
52
51
|
},
|
|
53
52
|
|
|
54
53
|
/**
|
|
@@ -185,8 +184,6 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
185
184
|
|
|
186
185
|
_openedChanged(opened, wasOpened) {
|
|
187
186
|
if (opened) {
|
|
188
|
-
this._setOverlayWidth();
|
|
189
|
-
|
|
190
187
|
this._scroller.style.maxHeight =
|
|
191
188
|
getComputedStyle(this).getPropertyValue(`--${this.__hostTagName}-overlay-max-height`) || '65vh';
|
|
192
189
|
|
|
@@ -274,32 +271,6 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
274
271
|
return !this.loading && !(this._items && this._items.length);
|
|
275
272
|
}
|
|
276
273
|
|
|
277
|
-
_positionTargetChanged(target) {
|
|
278
|
-
// We must update the overlay width when the positionTarget is set (or changes)
|
|
279
|
-
if (target) {
|
|
280
|
-
this._setOverlayWidth();
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
_setOverlayWidth() {
|
|
285
|
-
if (!this.positionTarget) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const inputWidth = `${this.positionTarget.clientWidth}px`;
|
|
289
|
-
const propPrefix = `${this.__hostTagName}-overlay`;
|
|
290
|
-
const customWidth = getComputedStyle(this).getPropertyValue(`--${propPrefix}-width`);
|
|
291
|
-
|
|
292
|
-
this.$.overlay.style.setProperty(`--_${propPrefix}-default-width`, inputWidth);
|
|
293
|
-
|
|
294
|
-
if (customWidth === '') {
|
|
295
|
-
this.$.overlay.style.removeProperty(`--${propPrefix}-width`);
|
|
296
|
-
} else {
|
|
297
|
-
this.$.overlay.style.setProperty(`--${propPrefix}-width`, customWidth);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
this.$.overlay._updatePosition();
|
|
301
|
-
}
|
|
302
|
-
|
|
303
274
|
/**
|
|
304
275
|
* Fired after the `vaadin-combo-box-dropdown` opens.
|
|
305
276
|
*
|
|
@@ -107,7 +107,7 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* Used by `
|
|
110
|
+
* Used by `InputControlMixin` as a reference to the clear button element.
|
|
111
111
|
* @protected
|
|
112
112
|
* @return {!HTMLElement}
|
|
113
113
|
*/
|
|
@@ -423,12 +423,29 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
+
/**
|
|
427
|
+
* @param {Event} event
|
|
428
|
+
* @private
|
|
429
|
+
*/
|
|
430
|
+
_onToggleButtonClick(event) {
|
|
431
|
+
// Prevent parent components such as `vaadin-grid`
|
|
432
|
+
// from handling the click event after it bubbles.
|
|
433
|
+
event.preventDefault();
|
|
434
|
+
|
|
435
|
+
if (this.opened) {
|
|
436
|
+
this.close();
|
|
437
|
+
} else {
|
|
438
|
+
this.open();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
426
442
|
/**
|
|
427
443
|
* @param {Event} event
|
|
428
444
|
* @protected
|
|
429
445
|
*/
|
|
430
|
-
_onHostClick(
|
|
446
|
+
_onHostClick(event) {
|
|
431
447
|
if (!this.autoOpenDisabled) {
|
|
448
|
+
event.preventDefault();
|
|
432
449
|
this.open();
|
|
433
450
|
}
|
|
434
451
|
}
|
|
@@ -442,11 +459,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
442
459
|
if (this._isClearButton(e)) {
|
|
443
460
|
this._handleClearButtonClick(e);
|
|
444
461
|
} else if (path.indexOf(this._toggleElement) > -1) {
|
|
445
|
-
|
|
446
|
-
this.close();
|
|
447
|
-
} else {
|
|
448
|
-
this.open();
|
|
449
|
-
}
|
|
462
|
+
this._onToggleButtonClick(e);
|
|
450
463
|
} else {
|
|
451
464
|
this._onHostClick(e);
|
|
452
465
|
}
|
|
@@ -456,12 +469,14 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
456
469
|
|
|
457
470
|
/**
|
|
458
471
|
* Override an event listener from `KeyboardMixin`.
|
|
459
|
-
*
|
|
460
|
-
*
|
|
472
|
+
*
|
|
473
|
+
* @param {KeyboardEvent} e
|
|
461
474
|
* @protected
|
|
462
475
|
* @override
|
|
463
476
|
*/
|
|
464
477
|
_onKeyDown(e) {
|
|
478
|
+
super._onKeyDown(e);
|
|
479
|
+
|
|
465
480
|
if (e.key === 'Tab') {
|
|
466
481
|
this.__restoreFocusOnClose = false;
|
|
467
482
|
} else if (e.key === 'ArrowDown') {
|
|
@@ -478,10 +493,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
478
493
|
|
|
479
494
|
// Prevent caret from moving
|
|
480
495
|
e.preventDefault();
|
|
481
|
-
} else if (e.key === 'Enter') {
|
|
482
|
-
this._onEnter(e);
|
|
483
|
-
} else if (e.key === 'Escape') {
|
|
484
|
-
this._onEscape(e);
|
|
485
496
|
}
|
|
486
497
|
}
|
|
487
498
|
|
|
@@ -574,7 +585,13 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
574
585
|
}
|
|
575
586
|
}
|
|
576
587
|
|
|
577
|
-
/**
|
|
588
|
+
/**
|
|
589
|
+
* Override an event listener from `KeyboardMixin`.
|
|
590
|
+
*
|
|
591
|
+
* @param {KeyboardEvent} e
|
|
592
|
+
* @protected
|
|
593
|
+
* @override
|
|
594
|
+
*/
|
|
578
595
|
_onEnter(e) {
|
|
579
596
|
// Do not commit value when custom values are disallowed and input value is not a valid option
|
|
580
597
|
// also stop propagation of the event, otherwise the user could submit a form while the input
|
|
@@ -600,8 +617,13 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
600
617
|
}
|
|
601
618
|
|
|
602
619
|
/**
|
|
620
|
+
* Override an event listener from `KeyboardMixin`.
|
|
621
|
+
* Do not call `super` in order to override clear
|
|
622
|
+
* button logic defined in `InputControlMixin`.
|
|
623
|
+
*
|
|
603
624
|
* @param {!KeyboardEvent} e
|
|
604
625
|
* @protected
|
|
626
|
+
* @override
|
|
605
627
|
*/
|
|
606
628
|
_onEscape(e) {
|
|
607
629
|
if (this.autoOpenDisabled) {
|
|
@@ -45,11 +45,17 @@ export class ComboBoxOverlay extends PositionMixin(OverlayElement) {
|
|
|
45
45
|
return memoizedTemplate;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
static get observers() {
|
|
49
|
+
return ['_setOverlayWidth(positionTarget, opened)'];
|
|
50
|
+
}
|
|
51
|
+
|
|
48
52
|
connectedCallback() {
|
|
49
53
|
super.connectedCallback();
|
|
50
54
|
|
|
51
55
|
const dropdown = this.__dataHost;
|
|
52
56
|
const comboBox = dropdown && dropdown.getRootNode().host;
|
|
57
|
+
this._comboBox = comboBox;
|
|
58
|
+
|
|
53
59
|
const hostDir = comboBox && comboBox.getAttribute('dir');
|
|
54
60
|
if (hostDir) {
|
|
55
61
|
this.setAttribute('dir', hostDir);
|
|
@@ -70,6 +76,23 @@ export class ComboBoxOverlay extends PositionMixin(OverlayElement) {
|
|
|
70
76
|
this.close();
|
|
71
77
|
}
|
|
72
78
|
}
|
|
79
|
+
|
|
80
|
+
_setOverlayWidth(positionTarget, opened) {
|
|
81
|
+
if (positionTarget && opened) {
|
|
82
|
+
const propPrefix = this.localName;
|
|
83
|
+
this.style.setProperty(`--_${propPrefix}-default-width`, `${positionTarget.clientWidth}px`);
|
|
84
|
+
|
|
85
|
+
const customWidth = getComputedStyle(this._comboBox).getPropertyValue(`--${propPrefix}-width`);
|
|
86
|
+
|
|
87
|
+
if (customWidth === '') {
|
|
88
|
+
this.style.removeProperty(`--${propPrefix}-width`);
|
|
89
|
+
} else {
|
|
90
|
+
this.style.setProperty(`--${propPrefix}-width`, customWidth);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this._updatePosition();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
73
96
|
}
|
|
74
97
|
|
|
75
98
|
customElements.define(ComboBoxOverlay.is, ComboBoxOverlay);
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -224,7 +224,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
|
-
* Used by `
|
|
227
|
+
* Used by `InputControlMixin` as a reference to the clear button element.
|
|
228
228
|
* @protected
|
|
229
229
|
* @return {!HTMLElement}
|
|
230
230
|
*/
|
|
@@ -282,7 +282,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
|
-
* Override method inherited from `
|
|
285
|
+
* Override method inherited from `InputControlMixin` to handle clear
|
|
286
286
|
* button click and stop event from propagating to the host element.
|
|
287
287
|
* @param {Event} event
|
|
288
288
|
* @protected
|