@vaadin/vaadin-combo-box
Advanced tools
Comparing version 5.4.6 to 5.4.7
@@ -13,3 +13,3 @@ { | ||
"name": "@vaadin/vaadin-combo-box", | ||
"version": "5.4.6", | ||
"version": "5.4.7", | ||
"main": "vaadin-combo-box.js", | ||
@@ -16,0 +16,0 @@ "author": "Vaadin Ltd", |
@@ -97,2 +97,13 @@ /** | ||
const index = e.detail.index; | ||
const currentScrollerPos = e.detail.currentScrollerPos; | ||
const allowedIndexRange = Math.floor(this.pageSize * 1.5); | ||
// Ignores the indexes, which are being re-sent during scrolling reset, | ||
// if the corresponding page is around the current scroller position. | ||
// Otherwise, there might be a last pages duplicates, which cause the | ||
// loading indicator hanging and blank items | ||
if (this._shouldSkipIndex(index, allowedIndexRange, currentScrollerPos)) { | ||
return; | ||
} | ||
if (index !== undefined) { | ||
@@ -137,2 +148,9 @@ const page = this._getPageForIndex(index); | ||
/** @private */ | ||
_shouldSkipIndex(index, allowedIndexRange, currentScrollerPos) { | ||
return currentScrollerPos !== 0 && | ||
index >= currentScrollerPos - allowedIndexRange && | ||
index <= currentScrollerPos + allowedIndexRange; | ||
} | ||
/** @private */ | ||
_shouldLoadPage(page) { | ||
@@ -193,4 +211,9 @@ if (!this.filteredItems || this._forceNextRequest) { | ||
}; | ||
this._pendingRequests[page] = callback; | ||
this.dataProvider(params, callback); | ||
if (!this._pendingRequests[page]) { | ||
// Don't request page if it's already being requested | ||
this._pendingRequests[page] = callback; | ||
this.dataProvider(params, callback); | ||
} | ||
} | ||
@@ -197,0 +220,0 @@ } |
@@ -51,3 +51,3 @@ /** | ||
<template> | ||
<vaadin-combo-box-item on-click="_onItemClick" index="[[__requestItemByIndex(item, index)]]" item="[[item]]" label="[[getItemLabel(item, _itemLabelPath)]]" selected="[[_isItemSelected(item, _selectedItem, _itemIdPath)]]" renderer="[[renderer]]" role\$="[[_getAriaRole(index)]]" aria-selected\$="[[_getAriaSelected(_focusedIndex,index)]]" focused="[[_isItemFocused(_focusedIndex,index)]]" tabindex="-1" theme\$="[[theme]]"> | ||
<vaadin-combo-box-item on-click="_onItemClick" index="[[__requestItemByIndex(item, index, _resetScrolling)]]" item="[[item]]" label="[[getItemLabel(item, _itemLabelPath)]]" selected="[[_isItemSelected(item, _selectedItem, _itemIdPath)]]" renderer="[[renderer]]" role\$="[[_getAriaRole(index)]]" aria-selected\$="[[_getAriaSelected(_focusedIndex,index)]]" focused="[[_isItemFocused(_focusedIndex,index)]]" tabindex="-1" theme\$="[[theme]]"> | ||
</vaadin-combo-box-item> | ||
@@ -106,7 +106,7 @@ </template> | ||
/** | ||
* Used to recognize scroller reset after new items have been set | ||
* to iron-list and to ignore unwanted pages load. If 'true', then | ||
* skip loading of the pages until it becomes 'false'. | ||
* Used to recognize if the filter changed, so to skip the | ||
* scrolling restore. If true, then scroll to 0 position. Restore | ||
* the previous position otherwise. | ||
*/ | ||
resetScrolling: { | ||
filterChanged: { | ||
type: Boolean, | ||
@@ -117,7 +117,7 @@ value: false | ||
/** | ||
* Used to recognize if the filter changed, so to skip the | ||
* scrolling restore. If true, then scroll to 0 position. Restore | ||
* the previous position otherwise. | ||
* Used to recognize scroller reset after new items have been set | ||
* to iron-list and to ignore unwanted pages load. If 'true', then | ||
* skip loading of the pages until it becomes 'false'. | ||
*/ | ||
filterChanged: { | ||
_resetScrolling: { | ||
type: Boolean, | ||
@@ -194,3 +194,3 @@ value: false | ||
this._oldScrollerPosition = currentScrollerPosition; | ||
this.resetScrolling = true; | ||
this._resetScrolling = true; | ||
} | ||
@@ -210,3 +210,3 @@ } | ||
this._scrollIntoView(Math.min(items.length - 1, this._oldScrollerPosition)); | ||
this.resetScrolling = false; | ||
this._resetScrolling = false; | ||
// reset position to 0 again in order to properly handle the filter | ||
@@ -366,6 +366,7 @@ // cases (scroll to 0 after typing the filter) | ||
*/ | ||
__requestItemByIndex(item, index) { | ||
__requestItemByIndex(item, index, resetScrolling) { | ||
if ((item instanceof ComboBoxPlaceholder) && index !== | ||
undefined && !this.resetScrolling) { | ||
this.dispatchEvent(new CustomEvent('index-requested', {detail: {index}})); | ||
undefined && !resetScrolling) { | ||
this.dispatchEvent(new CustomEvent('index-requested', {detail: | ||
{index: index, currentScrollerPos: this._oldScrollerPosition}})); | ||
} | ||
@@ -372,0 +373,0 @@ |
@@ -900,7 +900,9 @@ /** | ||
_itemsOrPathsChanged(e, itemValuePath, itemLabelPath) { | ||
if (e.value === undefined) { | ||
return; | ||
} | ||
if (e.path === 'items' || e.path === 'items.splices') { | ||
this.filteredItems = this.items ? this.items.slice(0) : this.items; | ||
if (this.items) { | ||
this.filteredItems = this.items.slice(0); | ||
} else if (this.__previousItems) { | ||
// Only clear filteredItems if the component had items previously but got cleared | ||
this.filteredItems = null; | ||
} | ||
@@ -915,2 +917,3 @@ const valueIndex = this._indexOfValue(this.value, this.items); | ||
} | ||
this.__previousItems = e.value; | ||
} | ||
@@ -920,5 +923,2 @@ | ||
_filteredItemsChanged(e, itemValuePath, itemLabelPath) { | ||
if (e.value === undefined) { | ||
return; | ||
} | ||
if (e.path === 'filteredItems' || e.path === 'filteredItems.splices') { | ||
@@ -925,0 +925,0 @@ this._setOverlayItems(this.filteredItems); |
@@ -232,3 +232,3 @@ /** | ||
static get version() { | ||
return '5.4.6'; | ||
return '5.4.7'; | ||
} | ||
@@ -235,0 +235,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
145127
3698
0