Commit 534ce8f7 authored by Tom Lukaszewicz's avatar Tom Lukaszewicz Committed by Josip Sokcevic

Tab Search: Add fixed height tabContents container

This CL adds a wrapping container around the tab search list items.

The height of the container is updated as the number of items to
be rendered is updated. This allows the tabContents container to
assert the final list height even as the items are rendered
piecemeal in dom-repeat's chunking mode.

This is dependent on the following:
  https://crrev.com/c/2417548

Bug: 1099917
Change-Id: Ib6e28cbac01f23e7f8dda918f19ff168be5989b6
Reviewed-on: https://chrome-internal-review.googlesource.com/c/chrome/browser/resources/tab_search/+/3281029Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819613}
parent 263f8ec9
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
position: relative; position: relative;
} }
#tabsContainer {
height: calc(var(--mwb-item-height) * var(--item-count, 0));
}
#no-results { #no-results {
color: var(--cr-primary-text-color); color: var(--cr-primary-text-color);
font-size: var(--mwb-primary-text-font-size); font-size: var(--mwb-primary-text-font-size);
...@@ -59,17 +63,19 @@ ...@@ -59,17 +63,19 @@
on-keydown="onSearchKeyDown_" on-search-changed="onSearchChanged_"> on-keydown="onSearchKeyDown_" on-search-changed="onSearchChanged_">
</tab-search-search-field> </tab-search-search-field>
<div id="tabs"> <div id="tabs">
<iron-selector id="selector" on-keydown="onItemKeyDown_" <div id="tabsContainer">
selected="{{selectedIndex_}}" selected-class="selected" role="listbox"> <iron-selector id="selector" on-keydown="onItemKeyDown_"
<template id="tabsList" is="dom-repeat" items="[[filteredOpenTabs_]]" selected="{{selectedIndex_}}" selected-class="selected" role="listbox">
initial-count="[[chunkingItemCount_]]"> <template id="tabsList" is="dom-repeat" items="[[filteredOpenTabs_]]"
<tab-search-item id="[[item.tabId]]" aria-label="[[ariaLabel_(item)]]" initial-count="[[chunkingItemCount_]]">
class="mwb-list-item" data="[[item]]" <tab-search-item id="[[item.tabId]]" aria-label="[[ariaLabel_(item)]]"
on-click="onItemClick_" on-close="onItemClose_" class="mwb-list-item" data="[[item]]"
on-focus="onItemFocus_" tabindex="0" role="option"> on-click="onItemClick_" on-close="onItemClose_"
</tab-search-item> on-focus="onItemFocus_" tabindex="0" role="option">
</template> </tab-search-item>
</iron-selector> </template>
</iron-selector>
</div>
</div> </div>
<div id="no-results" hidden="[[filteredOpenTabs_.length]]"> <div id="no-results" hidden="[[filteredOpenTabs_.length]]">
$i18n{noResultsFound} $i18n{noResultsFound}
......
...@@ -383,6 +383,13 @@ export class TabSearchAppElement extends PolymerElement { ...@@ -383,6 +383,13 @@ export class TabSearchAppElement extends PolymerElement {
b.lastActiveTimeTicks.internalValue - a.lastActiveTimeTicks.internalValue : b.lastActiveTimeTicks.internalValue - a.lastActiveTimeTicks.internalValue :
0); 0);
this.filteredOpenTabs_ = fuzzySearch(this.searchText_, result); this.filteredOpenTabs_ = fuzzySearch(this.searchText_, result);
// Update the item count in css so that the css rule can calculate the final
// height of the tabsContainer. This prevents the scrolling height from
// changing as list items are added to the dom incrementally via chunking
// mode.
this.$.tabsContainer.style
.setProperty("--item-count", this.filteredOpenTabs_.length.toString());
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment