@vaadin/multi-select-combo-box 23.1.0-rc3 → 23.2.0-alpha1

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/lit.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src/lit/renderer-directives.js';
package/lit.js ADDED
@@ -0,0 +1 @@
1
+ export * from './src/lit/renderer-directives.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/multi-select-combo-box",
3
- "version": "23.1.0-rc3",
3
+ "version": "23.2.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -19,6 +19,8 @@
19
19
  "main": "vaadin-multi-select-combo-box.js",
20
20
  "module": "vaadin-multi-select-combo-box.js",
21
21
  "files": [
22
+ "lit.js",
23
+ "lit.d.ts",
22
24
  "src",
23
25
  "theme",
24
26
  "vaadin-*.d.ts",
@@ -33,18 +35,19 @@
33
35
  ],
34
36
  "dependencies": {
35
37
  "@polymer/polymer": "^3.0.0",
36
- "@vaadin/combo-box": "23.1.0-rc3",
37
- "@vaadin/component-base": "23.1.0-rc3",
38
- "@vaadin/field-base": "23.1.0-rc3",
39
- "@vaadin/input-container": "23.1.0-rc3",
40
- "@vaadin/vaadin-lumo-styles": "23.1.0-rc3",
41
- "@vaadin/vaadin-material-styles": "23.1.0-rc3",
42
- "@vaadin/vaadin-themable-mixin": "23.1.0-rc3"
38
+ "@vaadin/combo-box": "23.2.0-alpha1",
39
+ "@vaadin/component-base": "23.2.0-alpha1",
40
+ "@vaadin/field-base": "23.2.0-alpha1",
41
+ "@vaadin/input-container": "23.2.0-alpha1",
42
+ "@vaadin/lit-renderer": "23.2.0-alpha1",
43
+ "@vaadin/vaadin-lumo-styles": "23.2.0-alpha1",
44
+ "@vaadin/vaadin-material-styles": "23.2.0-alpha1",
45
+ "@vaadin/vaadin-themable-mixin": "23.2.0-alpha1"
43
46
  },
44
47
  "devDependencies": {
45
48
  "@esm-bundle/chai": "^4.3.4",
46
49
  "@vaadin/testing-helpers": "^0.3.2",
47
50
  "sinon": "^13.0.2"
48
51
  },
49
- "gitHead": "49c312fbe0228adb559296d45655bbfd4eac6235"
52
+ "gitHead": "f226a2976c270d3d53c824f6e0a740a5d3382d91"
50
53
  }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { TemplateResult } from 'lit';
7
+ import { DirectiveResult } from 'lit/directive.js';
8
+ import { ComboBoxItemModel } from '@vaadin/combo-box/src/vaadin-combo-box.js';
9
+ import { LitRendererDirective } from '@vaadin/lit-renderer';
10
+ import { MultiSelectComboBox } from '../vaadin-multi-select-combo-box.js';
11
+
12
+ export type MultiSelectComboBoxLitRenderer<TItem> = (
13
+ item: TItem,
14
+ model: ComboBoxItemModel<TItem>,
15
+ comboBox: MultiSelectComboBox<TItem>,
16
+ ) => TemplateResult;
17
+
18
+ export class MultiSelectComboBoxRendererDirective<TItem> extends LitRendererDirective<
19
+ MultiSelectComboBox,
20
+ MultiSelectComboBoxLitRenderer<TItem>
21
+ > {
22
+ /**
23
+ * Adds the renderer callback to the combo-box.
24
+ */
25
+ addRenderer(): void;
26
+
27
+ /**
28
+ * Runs the renderer callback on the combo-box.
29
+ */
30
+ runRenderer(): void;
31
+
32
+ /**
33
+ * Removes the renderer callback from the combo-box.
34
+ */
35
+ removeRenderer(): void;
36
+ }
37
+
38
+ /**
39
+ * A Lit directive for rendering the content of the `<vaadin-multi-select-combo-box-item>` elements.
40
+ *
41
+ * The directive accepts a renderer callback returning a Lit template and assigns it to the combo-box
42
+ * via the `renderer` property. The renderer is called for each combo-box item when assigned
43
+ * and whenever a single dependency or an array of dependencies changes.
44
+ * It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
45
+ *
46
+ * Dependencies can be a single value or an array of values.
47
+ * Values are checked against previous values with strict equality (`===`),
48
+ * so the check won't detect nested property changes inside objects or arrays.
49
+ * When dependencies are provided as an array, each item is checked against the previous value
50
+ * at the same index with strict equality. Nested arrays are also checked only by strict
51
+ * equality.
52
+ *
53
+ * Example of usage:
54
+ * ```js
55
+ * `<vaadin-multi-select-combo-box
56
+ * ${multiSelectComboBoxRenderer((item, model, comboBox) => html`...`)}
57
+ * ></vaadin-multi-select-combo-box>`
58
+ * ```
59
+ *
60
+ * @param renderer the renderer callback that returns a Lit template.
61
+ * @param dependencies a single dependency or an array of dependencies
62
+ * which trigger a re-render when changed.
63
+ */
64
+ export declare function multiSelectComboBoxRenderer<TItem>(
65
+ renderer: MultiSelectComboBoxLitRenderer<TItem>,
66
+ dependencies?: unknown,
67
+ ): DirectiveResult<typeof MultiSelectComboBoxRendererDirective>;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { directive } from 'lit/directive.js';
7
+ import { LitRendererDirective } from '@vaadin/lit-renderer';
8
+
9
+ export class MultiSelectComboBoxRendererDirective extends LitRendererDirective {
10
+ /**
11
+ * Adds the renderer callback to the combo-box.
12
+ */
13
+ addRenderer() {
14
+ this.element.renderer = (root, comboBox, model) => {
15
+ this.renderRenderer(root, model.item, model, comboBox);
16
+ };
17
+ }
18
+
19
+ /**
20
+ * Runs the renderer callback on the combo-box.
21
+ */
22
+ runRenderer() {
23
+ this.element.requestContentUpdate();
24
+ }
25
+
26
+ /**
27
+ * Removes the renderer callback from the combo-box.
28
+ */
29
+ removeRenderer() {
30
+ this.element.renderer = null;
31
+ }
32
+ }
33
+
34
+ /**
35
+ * A Lit directive for rendering the content of the `<vaadin-multi-select-combo-box-item>` elements.
36
+ *
37
+ * The directive accepts a renderer callback returning a Lit template and assigns it to the combo-box
38
+ * via the `renderer` property. The renderer is called for each combo-box item when assigned
39
+ * and whenever a single dependency or an array of dependencies changes.
40
+ * It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
41
+ *
42
+ * Dependencies can be a single value or an array of values.
43
+ * Values are checked against previous values with strict equality (`===`),
44
+ * so the check won't detect nested property changes inside objects or arrays.
45
+ * When dependencies are provided as an array, each item is checked against the previous value
46
+ * at the same index with strict equality. Nested arrays are also checked only by strict
47
+ * equality.
48
+ *
49
+ * Example of usage:
50
+ * ```js
51
+ * `<vaadin-multi-select-combo-box
52
+ * ${multiSelectComboBoxRenderer((item, model, comboBox) => html`...`)}
53
+ * ></vaadin-multi-select-combo-box>`
54
+ * ```
55
+ *
56
+ * @param renderer the renderer callback that returns a Lit template.
57
+ * @param dependencies a single dependency or an array of dependencies
58
+ * which trigger a re-render when changed.
59
+ */
60
+ export const multiSelectComboBoxRenderer = directive(MultiSelectComboBoxRendererDirective);
@@ -3,7 +3,9 @@
3
3
  * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import './vaadin-multi-select-combo-box-dropdown.js';
6
+ import './vaadin-multi-select-combo-box-item.js';
7
+ import './vaadin-multi-select-combo-box-overlay.js';
8
+ import './vaadin-multi-select-combo-box-scroller.js';
7
9
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
8
10
  import { ComboBoxDataProviderMixin } from '@vaadin/combo-box/src/vaadin-combo-box-data-provider-mixin.js';
9
11
  import { ComboBoxMixin } from '@vaadin/combo-box/src/vaadin-combo-box-mixin.js';
@@ -34,22 +36,39 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
34
36
 
35
37
  <slot></slot>
36
38
 
37
- <vaadin-multi-select-combo-box-dropdown
38
- id="dropdown"
39
- opened="[[opened]]"
39
+ <vaadin-multi-select-combo-box-overlay
40
+ id="overlay"
41
+ hidden$="[[_isOverlayHidden(filteredItems, loading)]]"
42
+ opened="[[_overlayOpened]]"
43
+ loading$="[[loading]]"
44
+ theme$="[[_theme]]"
40
45
  position-target="[[_target]]"
41
- renderer="[[renderer]]"
42
- _focused-index="[[_focusedIndex]]"
43
- _item-id-path="[[itemIdPath]]"
44
- _item-label-path="[[itemLabelPath]]"
45
- loading="[[loading]]"
46
- theme="[[theme]]"
47
- ></vaadin-multi-select-combo-box-dropdown>
46
+ no-vertical-overlap
47
+ restore-focus-node="[[inputElement]]"
48
+ ></vaadin-multi-select-combo-box-overlay>
48
49
  `;
49
50
  }
50
51
 
51
52
  static get properties() {
52
53
  return {
54
+ /**
55
+ * A subset of items, filtered based on the user input.
56
+ */
57
+ filteredItems: {
58
+ type: Array,
59
+ notify: true,
60
+ },
61
+
62
+ /**
63
+ * When set to `true`, "loading" attribute is set
64
+ * on the host and the overlay element.
65
+ * @type {boolean}
66
+ */
67
+ loading: {
68
+ type: Boolean,
69
+ notify: true,
70
+ },
71
+
53
72
  /**
54
73
  * Total number of items.
55
74
  * @type {number | undefined}
@@ -59,6 +78,15 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
59
78
  notify: true,
60
79
  },
61
80
 
81
+ /**
82
+ * Selected items to render in the dropdown
83
+ * when the component is read-only.
84
+ */
85
+ selectedItems: {
86
+ type: Array,
87
+ value: () => [],
88
+ },
89
+
62
90
  _target: {
63
91
  type: Object,
64
92
  },
@@ -74,25 +102,26 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
74
102
  return this.querySelector('[part="clear-button"]');
75
103
  }
76
104
 
105
+ /**
106
+ * Tag name prefix used by scroller and items.
107
+ * @protected
108
+ * @return {string}
109
+ */
110
+ get _tagNamePrefix() {
111
+ return 'vaadin-multi-select-combo-box';
112
+ }
113
+
77
114
  /**
78
115
  * Override method inherited from the combo-box
79
116
  * to allow opening dropdown when readonly.
80
117
  * @override
81
118
  */
82
119
  open() {
83
- if (!this.disabled && !(this.readonly && this._getOverlayItems().length === 0)) {
120
+ if (!this.disabled && !(this.readonly && this.selectedItems.length === 0)) {
84
121
  this.opened = true;
85
122
  }
86
123
  }
87
124
 
88
- /**
89
- * @protected
90
- * @override
91
- */
92
- _getItemElements() {
93
- return Array.from(this.$.dropdown._scroller.querySelectorAll('vaadin-multi-select-combo-box-item'));
94
- }
95
-
96
125
  /** @protected */
97
126
  ready() {
98
127
  super.ready();
@@ -101,6 +130,20 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
101
130
  this._toggleElement = this.querySelector('.toggle-button');
102
131
  }
103
132
 
133
+ /**
134
+ * Override combo-box method to set correct owner for using by item renderers.
135
+ * This needs to be done before the scroller gets added to the DOM to ensure
136
+ * Lit directive works in case when combo-box is opened using attribute.
137
+ *
138
+ * @protected
139
+ * @override
140
+ */
141
+ _initScroller() {
142
+ const comboBox = this.getRootNode().host;
143
+
144
+ super._initScroller(comboBox);
145
+ }
146
+
104
147
  /**
105
148
  * Override method from `InputMixin`.
106
149
  *
@@ -246,6 +289,23 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
246
289
  );
247
290
  }
248
291
  }
292
+
293
+ /**
294
+ * Override method inherited from the combo-box
295
+ * to not request data provider when read-only.
296
+ *
297
+ * @param {number}
298
+ * @return {boolean}
299
+ * @protected
300
+ * @override
301
+ */
302
+ _shouldLoadPage(page) {
303
+ if (this.readonly) {
304
+ return false;
305
+ }
306
+
307
+ return super._shouldLoadPage(page);
308
+ }
249
309
  }
250
310
 
251
311
  customElements.define(MultiSelectComboBoxInternal.is, MultiSelectComboBoxInternal);
@@ -40,8 +40,7 @@ class MultiSelectComboBoxScroller extends ComboBoxScroller {
40
40
  return false;
41
41
  }
42
42
 
43
- const host = this.comboBox.getRootNode().host;
44
- return host._findIndex(item, host.selectedItems, itemIdPath) > -1;
43
+ return this.comboBox._findIndex(item, this.comboBox.selectedItems, itemIdPath) > -1;
45
44
  }
46
45
 
47
46
  /** @private */
@@ -3,7 +3,11 @@
3
3
  * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { ComboBoxDataProvider, ComboBoxDefaultItem, ComboBoxRenderer } from '@vaadin/combo-box/src/vaadin-combo-box.js';
6
+ import {
7
+ ComboBoxDataProvider,
8
+ ComboBoxDefaultItem,
9
+ ComboBoxItemModel,
10
+ } from '@vaadin/combo-box/src/vaadin-combo-box.js';
7
11
  import { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
8
12
  import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
9
13
  import { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
@@ -20,6 +24,12 @@ import { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
20
24
  import { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
21
25
  import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
22
26
 
27
+ export type MultiSelectComboBoxRenderer<TItem> = (
28
+ root: HTMLElement,
29
+ comboBox: MultiSelectComboBox<TItem>,
30
+ model: ComboBoxItemModel<TItem>,
31
+ ) => void;
32
+
23
33
  export interface MultiSelectComboBoxI18n {
24
34
  cleared: string;
25
35
  focused: string;
@@ -112,6 +122,7 @@ export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap
112
122
  * `invalid` | Set when the element is invalid
113
123
  * `focused` | Set when the element is focused
114
124
  * `focus-ring` | Set when the element is keyboard focused
125
+ * `loading` | Set when loading items from the data provider
115
126
  * `opened` | Set when the dropdown is open
116
127
  * `readonly` | Set to a readonly element
117
128
  *
@@ -231,6 +242,11 @@ declare class MultiSelectComboBox<TItem = ComboBoxDefaultItem> extends HTMLEleme
231
242
  */
232
243
  i18n: MultiSelectComboBoxI18n;
233
244
 
245
+ /**
246
+ * True when loading items from the data provider, false otherwise.
247
+ */
248
+ loading: boolean;
249
+
234
250
  /**
235
251
  * True if the dropdown is open, false otherwise.
236
252
  */
@@ -254,13 +270,13 @@ declare class MultiSelectComboBox<TItem = ComboBoxDefaultItem> extends HTMLEleme
254
270
  * Receives three arguments:
255
271
  *
256
272
  * - `root` The `<vaadin-multi-select-combo-box-item>` internal container DOM element.
257
- * - `comboBox` The reference to the `<vaadin-combo-box>` element.
273
+ * - `comboBox` The reference to the `<vaadin-multi-select-combo-box>` element.
258
274
  * - `model` The object with the properties related with the rendered
259
275
  * item, contains:
260
276
  * - `model.index` The index of the rendered item.
261
277
  * - `model.item` The item.
262
278
  */
263
- renderer: ComboBoxRenderer<TItem> | null | undefined;
279
+ renderer: MultiSelectComboBoxRenderer<TItem> | null | undefined;
264
280
 
265
281
  /**
266
282
  * The list of selected items.
@@ -278,6 +294,14 @@ declare class MultiSelectComboBox<TItem = ComboBoxDefaultItem> extends HTMLEleme
278
294
  */
279
295
  clearCache(): void;
280
296
 
297
+ /**
298
+ * Requests an update for the content of items.
299
+ * While performing the update, it invokes the renderer (passed in the `renderer` property) once an item.
300
+ *
301
+ * It is not guaranteed that the update happens immediately (synchronously) after it is requested.
302
+ */
303
+ requestContentUpdate(): void;
304
+
281
305
  addEventListener<K extends keyof MultiSelectComboBoxEventMap<TItem>>(
282
306
  type: K,
283
307
  listener: (this: MultiSelectComboBox<TItem>, ev: MultiSelectComboBoxEventMap<TItem>[K]) => void,
@@ -100,6 +100,7 @@ registerStyles('vaadin-multi-select-combo-box', [inputFieldShared, multiSelectCo
100
100
  * `invalid` | Set when the element is invalid
101
101
  * `focused` | Set when the element is focused
102
102
  * `focus-ring` | Set when the element is keyboard focused
103
+ * `loading` | Set when loading items from the data provider
103
104
  * `opened` | Set when the dropdown is open
104
105
  * `readonly` | Set to a readonly element
105
106
  *
@@ -152,7 +153,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
152
153
 
153
154
  <vaadin-multi-select-combo-box-internal
154
155
  id="comboBox"
155
- items="[[items]]"
156
+ items="[[__effectiveItems]]"
156
157
  item-id-path="[[itemIdPath]]"
157
158
  item-label-path="[[itemLabelPath]]"
158
159
  item-value-path="[[itemValuePath]]"
@@ -162,14 +163,17 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
162
163
  allow-custom-value="[[allowCustomValue]]"
163
164
  data-provider="[[dataProvider]]"
164
165
  filter="{{filter}}"
166
+ loading="{{loading}}"
165
167
  size="{{size}}"
166
- filtered-items="[[filteredItems]]"
168
+ filtered-items="[[__effectiveFilteredItems]]"
169
+ selected-items="[[selectedItems]]"
167
170
  opened="{{opened}}"
168
171
  renderer="[[renderer]]"
169
172
  theme$="[[_theme]]"
170
173
  on-combo-box-item-selected="_onComboBoxItemSelected"
171
174
  on-change="_onComboBoxChange"
172
175
  on-custom-value-set="_onCustomValueSet"
176
+ on-filtered-items-changed="_onFilteredItemsChanged"
173
177
  >
174
178
  <vaadin-multi-select-combo-box-container
175
179
  part="input-field"
@@ -298,6 +302,15 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
298
302
  },
299
303
  },
300
304
 
305
+ /**
306
+ * True when loading items from the data provider, false otherwise.
307
+ */
308
+ loading: {
309
+ type: Boolean,
310
+ value: false,
311
+ reflectToAttribute: true,
312
+ },
313
+
301
314
  /**
302
315
  * When present, it specifies that the field is read-only.
303
316
  */
@@ -359,7 +372,6 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
359
372
  */
360
373
  dataProvider: {
361
374
  type: Object,
362
- observer: '_dataProviderChanged',
363
375
  },
364
376
 
365
377
  /**
@@ -387,7 +399,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
387
399
  * Receives three arguments:
388
400
  *
389
401
  * - `root` The `<vaadin-multi-select-combo-box-item>` internal container DOM element.
390
- * - `comboBox` The reference to the `<vaadin-combo-box>` element.
402
+ * - `comboBox` The reference to the `<vaadin-multi-select-combo-box>` element.
391
403
  * - `model` The object with the properties related with the rendered
392
404
  * item, contains:
393
405
  * - `model.index` The index of the rendered item.
@@ -411,6 +423,18 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
411
423
  */
412
424
  filteredItems: Array,
413
425
 
426
+ /** @private */
427
+ __effectiveItems: {
428
+ type: Array,
429
+ computed: '__computeEffectiveItems(items, selectedItems, readonly)',
430
+ },
431
+
432
+ /** @private */
433
+ __effectiveFilteredItems: {
434
+ type: Array,
435
+ computed: '__computeEffectiveFilteredItems(items, filteredItems, selectedItems, readonly)',
436
+ },
437
+
414
438
  /** @protected */
415
439
  _hasValue: {
416
440
  type: Boolean,
@@ -487,6 +511,18 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
487
511
  }
488
512
  }
489
513
 
514
+ /**
515
+ * Requests an update for the content of items.
516
+ * While performing the update, it invokes the renderer (passed in the `renderer` property) once an item.
517
+ *
518
+ * It is not guaranteed that the update happens immediately (synchronously) after it is requested.
519
+ */
520
+ requestContentUpdate() {
521
+ if (this.$ && this.$.comboBox) {
522
+ this.$.comboBox.requestContentUpdate();
523
+ }
524
+ }
525
+
490
526
  /**
491
527
  * Override method inherited from `DisabledMixin` to forward disabled to chips.
492
528
  * @protected
@@ -582,15 +618,23 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
582
618
  }
583
619
  }
584
620
 
621
+ /**
622
+ * Implement two-way binding for the `filteredItems` property
623
+ * that can be set on the internal combo-box element.
624
+ *
625
+ * @param {CustomEvent} event
626
+ * @private
627
+ */
628
+ _onFilteredItemsChanged(event) {
629
+ const { value } = event.detail;
630
+ if (Array.isArray(value) || value == null) {
631
+ this.filteredItems = value;
632
+ }
633
+ }
634
+
585
635
  /** @private */
586
636
  _readonlyChanged(readonly, oldReadonly) {
587
- if (readonly) {
588
- this.__savedItems = this.$.comboBox._getOverlayItems();
589
- this.$.comboBox._setOverlayItems(Array.from(this.selectedItems));
590
- this.__updateChips();
591
- } else if (oldReadonly) {
592
- this.$.comboBox._setOverlayItems(this.__savedItems);
593
- this.__savedItems = null;
637
+ if (readonly || oldReadonly) {
594
638
  this.__updateChips();
595
639
  }
596
640
  }
@@ -637,17 +681,13 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
637
681
  // Re-render chips
638
682
  this.__updateChips();
639
683
 
640
- if (this.readonly) {
641
- this.$.comboBox._setOverlayItems(selectedItems);
642
- }
643
-
644
684
  // Update selected for dropdown items
645
- this.$.comboBox.requestContentUpdate();
685
+ this.requestContentUpdate();
646
686
  }
647
687
 
648
688
  /** @private */
649
689
  _getItemLabel(item) {
650
- return item && Object.prototype.hasOwnProperty.call(item, this.itemLabelPath) ? item[this.itemLabelPath] : item;
690
+ return this.$.comboBox._getItemLabel(item);
651
691
  }
652
692
 
653
693
  /** @private */
@@ -850,6 +890,18 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
850
890
  announce(this.i18n.cleared);
851
891
  }
852
892
 
893
+ /**
894
+ * Override an event listener from `InputControlMixin` to
895
+ * stop the change event re-targeted from the input.
896
+ *
897
+ * @param {!Event} event
898
+ * @protected
899
+ * @override
900
+ */
901
+ _onChange(event) {
902
+ event.stopPropagation();
903
+ }
904
+
853
905
  /**
854
906
  * Override an event listener from `KeyboardMixin`.
855
907
  * Do not call `super` in order to override clear
@@ -1030,6 +1082,16 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
1030
1082
  // and keep the overlay opened when clicking a chip.
1031
1083
  event.preventDefault();
1032
1084
  }
1085
+
1086
+ /** @private */
1087
+ __computeEffectiveItems(items, selectedItems, readonly) {
1088
+ return items && readonly ? selectedItems : items;
1089
+ }
1090
+
1091
+ /** @private */
1092
+ __computeEffectiveFilteredItems(items, filteredItems, selectedItems, readonly) {
1093
+ return !items && readonly ? selectedItems : filteredItems;
1094
+ }
1033
1095
  }
1034
1096
 
1035
1097
  customElements.define(MultiSelectComboBox.is, MultiSelectComboBox);
@@ -1,38 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import './vaadin-multi-select-combo-box-item.js';
7
- import './vaadin-multi-select-combo-box-overlay.js';
8
- import './vaadin-multi-select-combo-box-scroller.js';
9
- import { html } from '@polymer/polymer/lib/utils/html-tag.js';
10
- import { ComboBoxDropdown } from '@vaadin/combo-box/src/vaadin-combo-box-dropdown.js';
11
-
12
- /**
13
- * An element used internally by `<vaadin-multi-select-combo-box>`. Not intended to be used separately.
14
- *
15
- * @extends ComboBoxDropdown
16
- * @private
17
- */
18
- class MultiSelectComboBoxDropdown extends ComboBoxDropdown {
19
- static get is() {
20
- return 'vaadin-multi-select-combo-box-dropdown';
21
- }
22
-
23
- static get template() {
24
- return html`
25
- <vaadin-multi-select-combo-box-overlay
26
- id="overlay"
27
- hidden$="[[_isOverlayHidden(_items.*, loading)]]"
28
- loading$="[[loading]]"
29
- opened="{{_overlayOpened}}"
30
- theme$="[[theme]]"
31
- position-target="[[positionTarget]]"
32
- no-vertical-overlap
33
- ></vaadin-multi-select-combo-box-overlay>
34
- `;
35
- }
36
- }
37
-
38
- customElements.define(MultiSelectComboBoxDropdown.is, MultiSelectComboBoxDropdown);