@vaadin/combo-box 23.0.0-alpha1 → 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 +14 -14
- package/src/vaadin-combo-box-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-data-provider-mixin.js +2 -3
- package/src/vaadin-combo-box-dropdown.js +5 -12
- package/src/vaadin-combo-box-item.js +5 -3
- package/src/vaadin-combo-box-light.d.ts +1 -1
- package/src/vaadin-combo-box-light.js +4 -3
- package/src/vaadin-combo-box-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-mixin.js +62 -43
- package/src/vaadin-combo-box-overlay.js +1 -1
- package/src/vaadin-combo-box-placeholder.js +1 -1
- package/src/vaadin-combo-box-scroller.js +16 -11
- package/src/vaadin-combo-box.d.ts +1 -1
- package/src/vaadin-combo-box.js +4 -2
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
|
},
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"url": "https://github.com/vaadin/web-components/issues"
|
|
18
18
|
},
|
|
19
19
|
"main": "vaadin-combo-box.js",
|
|
20
|
+
"type": "module",
|
|
20
21
|
"files": [
|
|
21
22
|
"src",
|
|
22
23
|
"theme",
|
|
@@ -32,25 +33,24 @@
|
|
|
32
33
|
],
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
35
|
-
"@polymer/iron-resizable-behavior": "^3.0.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
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { ComboBoxPlaceholder } from './vaadin-combo-box-placeholder.js';
|
|
@@ -158,9 +158,8 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
158
158
|
const loadedItem = this.filteredItems[page * this.pageSize];
|
|
159
159
|
if (loadedItem !== undefined) {
|
|
160
160
|
return loadedItem instanceof ComboBoxPlaceholder;
|
|
161
|
-
} else {
|
|
162
|
-
return this.size === undefined;
|
|
163
161
|
}
|
|
162
|
+
return this.size === undefined;
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
/** @private */
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
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
|
}
|
|
@@ -31,6 +29,8 @@ export class ComboBoxDropdown extends mixinBehaviors(IronResizableBehavior, Poly
|
|
|
31
29
|
theme$="[[theme]]"
|
|
32
30
|
position-target="[[positionTarget]]"
|
|
33
31
|
no-vertical-overlap
|
|
32
|
+
restore-focus-on-close="[[restoreFocusOnClose]]"
|
|
33
|
+
restore-focus-node="[[restoreFocusNode]]"
|
|
34
34
|
></vaadin-combo-box-overlay>
|
|
35
35
|
`;
|
|
36
36
|
}
|
|
@@ -171,14 +171,6 @@ export class ComboBoxDropdown extends mixinBehaviors(IronResizableBehavior, Poly
|
|
|
171
171
|
this._overlayOpened = false;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
notifyResize() {
|
|
175
|
-
super.notifyResize();
|
|
176
|
-
|
|
177
|
-
if (this.positionTarget && this.opened) {
|
|
178
|
-
this._setOverlayWidth();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
174
|
_fireTouchAction(sourceEvent) {
|
|
183
175
|
this.dispatchEvent(
|
|
184
176
|
new CustomEvent('vaadin-overlay-touch-action', {
|
|
@@ -262,6 +254,7 @@ export class ComboBoxDropdown extends mixinBehaviors(IronResizableBehavior, Poly
|
|
|
262
254
|
}
|
|
263
255
|
}
|
|
264
256
|
|
|
257
|
+
// eslint-disable-next-line max-params
|
|
265
258
|
__updateScroller(scroller, items, opened, loading, selectedItem, itemIdPath, focusedIndex, renderer, theme) {
|
|
266
259
|
if (scroller) {
|
|
267
260
|
scroller.setProperties({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -140,7 +140,7 @@ export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/** @private */
|
|
143
|
-
__rendererOrItemChanged(renderer, index, item
|
|
143
|
+
__rendererOrItemChanged(renderer, index, item) {
|
|
144
144
|
if (item === undefined || index === undefined) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
@@ -161,7 +161,9 @@ export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
161
161
|
|
|
162
162
|
/** @private */
|
|
163
163
|
__updateLabel(label, renderer) {
|
|
164
|
-
if (renderer)
|
|
164
|
+
if (renderer) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
165
167
|
|
|
166
168
|
this.textContent = label;
|
|
167
169
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-combo-box-dropdown.js';
|
|
@@ -79,6 +79,8 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
|
|
|
79
79
|
id="dropdown"
|
|
80
80
|
opened="[[opened]]"
|
|
81
81
|
position-target="[[inputElement]]"
|
|
82
|
+
restore-focus-on-close="[[__restoreFocusOnClose]]"
|
|
83
|
+
restore-focus-node="[[inputElement]]"
|
|
82
84
|
renderer="[[renderer]]"
|
|
83
85
|
_focused-index="[[_focusedIndex]]"
|
|
84
86
|
_item-id-path="[[itemIdPath]]"
|
|
@@ -133,9 +135,8 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
|
|
|
133
135
|
checkValidity() {
|
|
134
136
|
if (this.inputElement.validate) {
|
|
135
137
|
return this.inputElement.validate();
|
|
136
|
-
} else {
|
|
137
|
-
return super.checkValidity();
|
|
138
138
|
}
|
|
139
|
+
return super.checkValidity();
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
/**
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
7
|
+
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
8
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
9
|
import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
9
10
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
10
11
|
import { InputMixin } from '@vaadin/field-base/src/input-mixin.js';
|
|
12
|
+
import { VirtualKeyboardController } from '@vaadin/field-base/src/virtual-keyboard-controller.js';
|
|
11
13
|
import { ComboBoxPlaceholder } from './vaadin-combo-box-placeholder.js';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* @polymerMixin
|
|
17
|
+
* @param {function(new:HTMLElement)} subclass
|
|
15
18
|
*/
|
|
16
19
|
export const ComboBoxMixin = (subclass) =>
|
|
17
|
-
class VaadinComboBoxMixinElement extends KeyboardMixin(InputMixin(DisabledMixin(subclass))) {
|
|
20
|
+
class VaadinComboBoxMixinElement extends ControllerMixin(KeyboardMixin(InputMixin(DisabledMixin(subclass)))) {
|
|
18
21
|
static get properties() {
|
|
19
22
|
return {
|
|
20
23
|
/**
|
|
@@ -190,7 +193,10 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
190
193
|
},
|
|
191
194
|
|
|
192
195
|
/** @private */
|
|
193
|
-
_closeOnBlurIsPrevented: Boolean
|
|
196
|
+
_closeOnBlurIsPrevented: Boolean,
|
|
197
|
+
|
|
198
|
+
/** @private */
|
|
199
|
+
__restoreFocusOnClose: Boolean
|
|
194
200
|
};
|
|
195
201
|
}
|
|
196
202
|
|
|
@@ -292,6 +298,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
292
298
|
this.addEventListener('touchstart', bringToFrontListener);
|
|
293
299
|
|
|
294
300
|
processTemplates(this);
|
|
301
|
+
|
|
302
|
+
this.addController(new VirtualKeyboardController(this));
|
|
295
303
|
}
|
|
296
304
|
|
|
297
305
|
/**
|
|
@@ -305,6 +313,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
305
313
|
return;
|
|
306
314
|
}
|
|
307
315
|
|
|
316
|
+
this.$.dropdown._scroller.requestContentUpdate();
|
|
317
|
+
|
|
308
318
|
this._getItemElements().forEach((item) => {
|
|
309
319
|
item.requestContentUpdate();
|
|
310
320
|
});
|
|
@@ -364,6 +374,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
364
374
|
if (!this.hasAttribute('focused') && !isTouch) {
|
|
365
375
|
this.focus();
|
|
366
376
|
}
|
|
377
|
+
|
|
378
|
+
this.__restoreFocusOnClose = true;
|
|
367
379
|
} else {
|
|
368
380
|
this._onClosed();
|
|
369
381
|
if (this._openedWithFocusRing && this.hasAttribute('focused')) {
|
|
@@ -404,6 +416,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
404
416
|
_handleClearButtonClick(event) {
|
|
405
417
|
event.preventDefault();
|
|
406
418
|
this._clear();
|
|
419
|
+
|
|
420
|
+
// De-select dropdown item
|
|
421
|
+
if (this.opened) {
|
|
422
|
+
this.requestContentUpdate();
|
|
423
|
+
}
|
|
407
424
|
}
|
|
408
425
|
|
|
409
426
|
/** @private */
|
|
@@ -435,23 +452,25 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
435
452
|
* @override
|
|
436
453
|
*/
|
|
437
454
|
_onKeyDown(e) {
|
|
438
|
-
if (e.
|
|
455
|
+
if (e.key === 'Tab') {
|
|
456
|
+
this.__restoreFocusOnClose = false;
|
|
457
|
+
} else if (e.key === 'ArrowDown') {
|
|
439
458
|
this._closeOnBlurIsPrevented = true;
|
|
440
459
|
this._onArrowDown();
|
|
441
460
|
this._closeOnBlurIsPrevented = false;
|
|
442
461
|
|
|
443
462
|
// prevent caret from moving
|
|
444
463
|
e.preventDefault();
|
|
445
|
-
} else if (e.
|
|
464
|
+
} else if (e.key === 'ArrowUp') {
|
|
446
465
|
this._closeOnBlurIsPrevented = true;
|
|
447
466
|
this._onArrowUp();
|
|
448
467
|
this._closeOnBlurIsPrevented = false;
|
|
449
468
|
|
|
450
469
|
// prevent caret from moving
|
|
451
470
|
e.preventDefault();
|
|
452
|
-
} else if (e.
|
|
471
|
+
} else if (e.key === 'Enter') {
|
|
453
472
|
this._onEnter(e);
|
|
454
|
-
} else if (e.
|
|
473
|
+
} else if (e.key === 'Escape') {
|
|
455
474
|
this._onEscape(e);
|
|
456
475
|
}
|
|
457
476
|
}
|
|
@@ -581,25 +600,23 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
581
600
|
// The clear button is visible and the overlay is closed, so clear the value.
|
|
582
601
|
this._clear();
|
|
583
602
|
}
|
|
584
|
-
} else {
|
|
603
|
+
} else if (this.opened) {
|
|
585
604
|
// Auto-open is enabled
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
e.stopPropagation();
|
|
605
|
+
// The overlay is open
|
|
606
|
+
e.stopPropagation();
|
|
589
607
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
} else if (this.clearButtonVisible && !!this.value) {
|
|
599
|
-
e.stopPropagation();
|
|
600
|
-
// The clear button is visible and the overlay is closed, so clear the value.
|
|
601
|
-
this._clear();
|
|
608
|
+
if (this._focusedIndex > -1) {
|
|
609
|
+
// An item is focused, revert the input to the filtered value
|
|
610
|
+
this._focusedIndex = -1;
|
|
611
|
+
this._revertInputValue();
|
|
612
|
+
} else {
|
|
613
|
+
// No item is focused, cancel the change and close the overlay
|
|
614
|
+
this.cancel();
|
|
602
615
|
}
|
|
616
|
+
} else if (this.clearButtonVisible && !!this.value) {
|
|
617
|
+
e.stopPropagation();
|
|
618
|
+
// The clear button is visible and the overlay is closed, so clear the value.
|
|
619
|
+
this._clear();
|
|
603
620
|
}
|
|
604
621
|
}
|
|
605
622
|
|
|
@@ -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,17 +702,20 @@ 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
|
+
// An item matching by label was not found, but custom values are allowed.
|
|
718
|
+
// Dispatch a custom-value-set event with the input value.
|
|
701
719
|
const e = new CustomEvent('custom-value-set', {
|
|
702
720
|
detail: this._inputElementValue,
|
|
703
721
|
composed: true,
|
|
@@ -710,9 +728,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
710
728
|
this._selectItemForValue(customValue);
|
|
711
729
|
this.value = customValue;
|
|
712
730
|
}
|
|
713
|
-
} else if (!this.allowCustomValue && !this.opened &&
|
|
714
|
-
|
|
731
|
+
} else if (!this.allowCustomValue && !this.opened && itemMatchingByLabel) {
|
|
732
|
+
// An item matching by label was found, select it.
|
|
733
|
+
this.value = this._getItemValue(itemMatchingByLabel);
|
|
715
734
|
} else {
|
|
735
|
+
// Revert the input value
|
|
716
736
|
this._inputElementValue = this.selectedItem ? this._getItemLabel(this.selectedItem) : this.value || '';
|
|
717
737
|
}
|
|
718
738
|
}
|
|
@@ -820,11 +840,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
820
840
|
}
|
|
821
841
|
}
|
|
822
842
|
|
|
823
|
-
/** @private */
|
|
824
|
-
_resizeDropdown() {
|
|
825
|
-
this.$.dropdown.notifyResize();
|
|
826
|
-
}
|
|
827
|
-
|
|
828
843
|
/** @private */
|
|
829
844
|
_selectedItemChanged(selectedItem) {
|
|
830
845
|
if (selectedItem === null || selectedItem === undefined) {
|
|
@@ -931,10 +946,14 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
931
946
|
if (e.path === 'filteredItems' || e.path === 'filteredItems.splices') {
|
|
932
947
|
this._setOverlayItems(this.filteredItems);
|
|
933
948
|
|
|
934
|
-
this.
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
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
|
+
}
|
|
938
957
|
|
|
939
958
|
// see https://github.com/vaadin/web-components/issues/2615
|
|
940
959
|
if (this.selectedItem === null && this._focusedIndex >= 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { OverlayElement } from '@vaadin/vaadin-overlay/src/vaadin-overlay.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -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;
|
|
@@ -221,9 +227,8 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
221
227
|
return false;
|
|
222
228
|
} else if (itemIdPath && item !== undefined && selectedItem !== undefined) {
|
|
223
229
|
return this.get(itemIdPath, item) === this.get(itemIdPath, selectedItem);
|
|
224
|
-
} else {
|
|
225
|
-
return item === selectedItem;
|
|
226
230
|
}
|
|
231
|
+
return item === selectedItem;
|
|
227
232
|
}
|
|
228
233
|
|
|
229
234
|
/** @private */
|
|
@@ -233,29 +238,29 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
233
238
|
this.__virtualizer.flush();
|
|
234
239
|
// Ensure the total count of items is properly announced.
|
|
235
240
|
this.setAttribute('aria-setsize', items.length);
|
|
236
|
-
this.
|
|
241
|
+
this.requestContentUpdate();
|
|
237
242
|
}
|
|
238
243
|
}
|
|
239
244
|
|
|
240
245
|
/** @private */
|
|
241
246
|
__loadingChanged(loading) {
|
|
242
247
|
if (this.__virtualizer && !loading) {
|
|
243
|
-
setTimeout(() => this.
|
|
248
|
+
setTimeout(() => this.requestContentUpdate());
|
|
244
249
|
}
|
|
245
250
|
}
|
|
246
251
|
|
|
247
252
|
/** @private */
|
|
248
253
|
__focusedIndexChanged(index) {
|
|
249
254
|
if (this.__virtualizer && index >= 0) {
|
|
250
|
-
this.
|
|
255
|
+
this.requestContentUpdate();
|
|
251
256
|
this.scrollIntoView(index);
|
|
252
257
|
}
|
|
253
258
|
}
|
|
254
259
|
|
|
255
260
|
/** @private */
|
|
256
261
|
__rendererChanged(renderer, oldRenderer) {
|
|
257
|
-
if (
|
|
258
|
-
this.
|
|
262
|
+
if (renderer || oldRenderer) {
|
|
263
|
+
this.requestContentUpdate();
|
|
259
264
|
}
|
|
260
265
|
}
|
|
261
266
|
|
|
@@ -288,7 +293,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
288
293
|
el.id = `${this.__hostTagName}-item-${index}`;
|
|
289
294
|
el.setAttribute('role', this.__getAriaRole(index));
|
|
290
295
|
el.setAttribute('aria-selected', this.__getAriaSelected(focusedIndex, index));
|
|
291
|
-
el.setAttribute('aria-posinset', index);
|
|
296
|
+
el.setAttribute('aria-posinset', index + 1);
|
|
292
297
|
|
|
293
298
|
if (this.theme) {
|
|
294
299
|
el.setAttribute('theme', this.theme);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
@@ -201,6 +201,8 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
201
201
|
opened="[[opened]]"
|
|
202
202
|
renderer="[[renderer]]"
|
|
203
203
|
position-target="[[_positionTarget]]"
|
|
204
|
+
restore-focus-on-close="[[__restoreFocusOnClose]]"
|
|
205
|
+
restore-focus-node="[[inputElement]]"
|
|
204
206
|
_focused-index="[[_focusedIndex]]"
|
|
205
207
|
_item-id-path="[[itemIdPath]]"
|
|
206
208
|
_item-label-path="[[itemLabelPath]]"
|
|
@@ -242,7 +244,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
242
244
|
this.ariaTarget = input;
|
|
243
245
|
})
|
|
244
246
|
);
|
|
245
|
-
this.addController(new LabelledInputController(this.inputElement, this.
|
|
247
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
246
248
|
this._positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|
|
247
249
|
this._toggleElement = this.$.toggleButton;
|
|
248
250
|
}
|