@vaadin/combo-box 23.1.7 → 23.1.9

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.7",
3
+ "version": "23.1.9",
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.7",
40
- "@vaadin/field-base": "~23.1.7",
41
- "@vaadin/input-container": "~23.1.7",
42
- "@vaadin/item": "~23.1.7",
43
- "@vaadin/lit-renderer": "~23.1.7",
44
- "@vaadin/vaadin-lumo-styles": "~23.1.7",
45
- "@vaadin/vaadin-material-styles": "~23.1.7",
46
- "@vaadin/vaadin-overlay": "~23.1.7",
47
- "@vaadin/vaadin-themable-mixin": "~23.1.7"
39
+ "@vaadin/component-base": "~23.1.9",
40
+ "@vaadin/field-base": "~23.1.9",
41
+ "@vaadin/input-container": "~23.1.9",
42
+ "@vaadin/item": "~23.1.9",
43
+ "@vaadin/lit-renderer": "~23.1.9",
44
+ "@vaadin/vaadin-lumo-styles": "~23.1.9",
45
+ "@vaadin/vaadin-material-styles": "~23.1.9",
46
+ "@vaadin/vaadin-overlay": "~23.1.9",
47
+ "@vaadin/vaadin-themable-mixin": "~23.1.9"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@esm-bundle/chai": "^4.3.4",
51
- "@vaadin/polymer-legacy-adapter": "~23.1.7",
51
+ "@vaadin/polymer-legacy-adapter": "~23.1.9",
52
52
  "@vaadin/testing-helpers": "^0.3.2",
53
- "@vaadin/text-field": "~23.1.7",
53
+ "@vaadin/text-field": "~23.1.9",
54
54
  "lit": "^2.0.0",
55
55
  "sinon": "^13.0.2"
56
56
  },
57
- "gitHead": "879a4e5e6a245809bafa0ef2b5cdb24aef72565d"
57
+ "gitHead": "ad8461e09f049c3f04f50278d38d0f5a98604904"
58
58
  }
@@ -90,6 +90,7 @@ export class ComboBoxScroller extends PolymerElement {
90
90
  */
91
91
  selectedItem: {
92
92
  type: Object,
93
+ observer: '__selectedItemChanged',
93
94
  },
94
95
 
95
96
  /**
@@ -245,7 +246,14 @@ export class ComboBoxScroller extends PolymerElement {
245
246
  /** @private */
246
247
  __loadingChanged(loading) {
247
248
  if (this.__virtualizer && !loading) {
248
- setTimeout(() => this.requestContentUpdate());
249
+ this.requestContentUpdate();
250
+ }
251
+ }
252
+
253
+ /** @private */
254
+ __selectedItemChanged() {
255
+ if (this.__virtualizer) {
256
+ this.requestContentUpdate();
249
257
  }
250
258
  }
251
259
 
@@ -292,7 +300,7 @@ export class ComboBoxScroller extends PolymerElement {
292
300
 
293
301
  el.setProperties({
294
302
  item,
295
- index: this.__requestItemByIndex(item, index),
303
+ index,
296
304
  label: this.getItemLabel(item),
297
305
  selected: this.__isItemSelected(item, this.selectedItem, this.itemIdPath),
298
306
  renderer: this.renderer,
@@ -309,6 +317,10 @@ export class ComboBoxScroller extends PolymerElement {
309
317
  } else {
310
318
  el.removeAttribute('theme');
311
319
  }
320
+
321
+ if (item instanceof ComboBoxPlaceholder) {
322
+ this.__requestItemByIndex(index);
323
+ }
312
324
  }
313
325
 
314
326
  /** @private */
@@ -349,19 +361,29 @@ export class ComboBoxScroller extends PolymerElement {
349
361
  }
350
362
 
351
363
  /**
352
- * If dataProvider is used, dispatch a request for the item’s index if
353
- * the item is a placeholder object.
364
+ * Dispatches an `index-requested` event for the given index to notify
365
+ * the data provider that it should start loading the page containing the requested index.
354
366
  *
355
- * @return {number}
367
+ * The event is dispatched asynchronously to prevent an immediate page request and therefore
368
+ * a possible infinite recursion in case the data provider implements page request cancelation logic
369
+ * by invoking data provider page callbacks with an empty array.
370
+ * The infinite recursion may occur otherwise since invoking a data provider page callback with an empty array
371
+ * triggers a synchronous scroller update and, if the callback corresponds to the currently visible page,
372
+ * the scroller will synchronously request the page again which may lead to looping in the end.
373
+ * That was the case for the Flow counterpart:
374
+ * https://github.com/vaadin/flow-components/issues/3553#issuecomment-1239344828
356
375
  */
357
- __requestItemByIndex(item, index) {
358
- if (item instanceof ComboBoxPlaceholder && index !== undefined) {
376
+ __requestItemByIndex(index) {
377
+ requestAnimationFrame(() => {
359
378
  this.dispatchEvent(
360
- new CustomEvent('index-requested', { detail: { index, currentScrollerPos: this._oldScrollerPosition } }),
379
+ new CustomEvent('index-requested', {
380
+ detail: {
381
+ index,
382
+ currentScrollerPos: this._oldScrollerPosition,
383
+ },
384
+ }),
361
385
  );
362
- }
363
-
364
- return index;
386
+ });
365
387
  }
366
388
 
367
389
  /** @private */