Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace iron-list with virtualizer in combo-box #2339

Merged
merged 16 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions packages/vaadin-combo-box/src/vaadin-combo-box-dropdown-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class ComboBoxDropdownWrapperElement extends PolymerElement {
/* Fixes scrollbar disappearing when 'Show scroll bars: Always' enabled in Safari */
box-shadow: 0 0 0 white;
}

#selector {
border-width: var(--_vaadin-combo-box-items-container-border-width);
border-style: var(--_vaadin-combo-box-items-container-border-style);
border-color: var(--_vaadin-combo-box-items-container-border-color);
}
jouni marked this conversation as resolved.
Show resolved Hide resolved
</style>

<div id="scroller" on-click="_stopPropagation" style="min-height: 1px">
web-padawan marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -204,10 +210,6 @@ class ComboBoxDropdownWrapperElement extends PolymerElement {
return [];
}

_isNotEmpty(items) {
return !this._isEmpty(items);
}

_isEmpty(items) {
return !items || !items.length;
}
Expand All @@ -224,7 +226,7 @@ class ComboBoxDropdownWrapperElement extends PolymerElement {
if (this._isEmpty(items)) {
this.$.dropdown.__emptyItems = true;
}
this.$.dropdown.opened = !!(opened && (loading || this._isNotEmpty(items)));
this.$.dropdown.opened = !!(opened && (loading || !this._isEmpty(items)));
this.$.dropdown.__emptyItems = false;
}

Expand Down Expand Up @@ -425,21 +427,6 @@ class ComboBoxDropdownWrapperElement extends PolymerElement {
});
}

get _viewportTotalPaddingBottom() {
if (this._cachedViewportTotalPaddingBottom === undefined) {
const itemsStyle = window.getComputedStyle(this._selector.$.items);
this._cachedViewportTotalPaddingBottom = [itemsStyle.paddingBottom, itemsStyle.borderBottomWidth]
.map((v) => {
return parseInt(v, 10);
})
.reduce((sum, v) => {
return sum + v;
});
}

return this._cachedViewportTotalPaddingBottom;
}

_visibleItemsCount() {
// Ensure items are positioned
this.__virtualizer.scrollToIndex(this.__virtualizer.firstVisibleIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ registerStyles(
}

:host {
/* TODO: using a legacy mixin (unsupported) */
--iron-list-items-container: {
border-width: var(--lumo-space-xs);
border-style: solid;
border-color: transparent;
}
--_vaadin-combo-box-items-container-border-width: var(--lumo-space-xs);
--_vaadin-combo-box-items-container-border-style: solid;
--_vaadin-combo-box-items-container-border-color: transparent;
}

/* Loading state */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ registerStyles(
'vaadin-combo-box-overlay',
css`
:host {
/* TODO using a legacy mixin (unsupported) */
--iron-list-items-container: {
border-width: 8px 0;
border-style: solid;
border-color: transparent;
}
--_vaadin-combo-box-items-container-border-width: 8px 0;
--_vaadin-combo-box-items-container-border-style: solid;
--_vaadin-combo-box-items-container-border-color: transparent;
}

[part='overlay'] {
Expand Down