Commit 002d437b authored by Esmael El-Moslimany's avatar Esmael El-Moslimany Committed by Commit Bot

Settings WebUI: settings-startup-urls-page, fire iron-resize when the

scrollHeight is 1px and another when the scrollHeight is more than 1px

Also fixed the following edge case.

1. Two tabs are open with chrome://settings.
2. The background tab has not been viewed.
3. In the active tab, cycle through the on startup radios.
4. Then choose "continue where you left off".
5. Make the background tab active.
6. Change the on startup setting to show the specific pages list.

The issue is the iron-list render code is running when the physical
height is 1px. Initially the iron-list has zero physical items. It
creates a minimum default of 3 physical items. After the render is
completed, the scrollHeight is updated to the correct value and more
physical items need to be created. This is done with a second
iron-resize.

Bug: 987893
Change-Id: I3a638ed8320e776a65a5b3b783514cdfecb47419
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1758219
Commit-Queue: Esmael Elmoslimany <aee@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688343}
parent d6c91097
...@@ -79,30 +79,46 @@ const CrScrollableBehavior = { ...@@ -79,30 +79,46 @@ const CrScrollableBehavior = {
this.requestUpdateScroll(); this.requestUpdateScroll();
let nodeList = this.root.querySelectorAll('[scrollable] iron-list'); const nodeList = this.root.querySelectorAll('[scrollable] iron-list');
if (!nodeList.length) { if (!nodeList.length) {
return; return;
} }
let nodesToResize = Array.from(nodeList).map(node => ({
node: node,
lastScrollHeight: 0,
}));
// Use setInterval to avoid initial render / sizing issues. // Use setInterval to avoid initial render / sizing issues.
this.intervalId_ = window.setInterval(function() { this.intervalId_ = window.setInterval(() => {
const unreadyNodes = []; const checkAgain = [];
for (let i = 0; i < nodeList.length; i++) { nodesToResize.forEach(({node, lastScrollHeight}) => {
const node = nodeList[i]; const scrollHeight = node.parentNode.scrollHeight;
if (node.parentNode.scrollHeight == 0) { // A hidden scroll-container has a height of 0. When not hidden, it has
unreadyNodes.push(node); // a min-height of 1px and the iron-list needs a resize to show the
continue; // initial items and update the |scrollHeight|. The initial item count
// is determined by the |scrollHeight|. A scrollHeight of 1px will
// result in the minimum default item count (currently 3). After the
// |scrollHeight| is updated to be greater than 1px, another resize is
// needed to correctly calculate the number of physical iron-list items
// to render.
if (scrollHeight != lastScrollHeight) {
const ironList = /** @type {!IronListElement} */ (node);
ironList.notifyResize();
} }
const ironList = /** @type {!IronListElement} */ (node); if (scrollHeight <= 1) {
ironList.notifyResize(); checkAgain.push({
} node: node,
if (unreadyNodes.length == 0) { lastScrollHeight: scrollHeight,
});
}
});
if (checkAgain.length == 0) {
window.clearInterval(this.intervalId_); window.clearInterval(this.intervalId_);
this.intervalId_ = null; this.intervalId_ = null;
} else { } else {
nodeList = unreadyNodes; nodesToResize = checkAgain;
} }
}.bind(this), 10); }, 10);
}, },
/** /**
......
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