Commit 02061243 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[directory-tree] Scroll Recents item to the top of its box

cr.ui.tree uses this.labelElement.scrollIntoViewIfNeeded() to scroll a
tree row into view. However, for the "Recent" item, which is always at
the top of the tree, that only scrolls as far as its label, causing it
to be drawn cut-off (see example image on the bug).

Fix that: by overriding the Recent labelElement.scrollIntoViewIfNeeded
to this.scrollIntoView, so the entire Recent box is shown (no cut-off)
when cr.ui.tree scrolls to the Recent item.

Test: the methods used here are web-apis and Blink tests those.
No-presubmit: true
No-try: true
Bug: 1027973
Change-Id: I21370d3fd9aa34a781a8aff1e9fbc006f8e0053d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933670
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Auto-Submit: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718499}
parent 9c3236e6
...@@ -1736,6 +1736,12 @@ class FakeItem extends TreeItem { ...@@ -1736,6 +1736,12 @@ class FakeItem extends TreeItem {
icon.classList.add('item-icon'); icon.classList.add('item-icon');
icon.setAttribute('root-type-icon', rootType); icon.setAttribute('root-type-icon', rootType);
if (rootType === VolumeManagerCommon.RootType.RECENT) {
this.labelElement.scrollIntoViewIfNeeded = () => {
this.scrollIntoView(true);
};
}
if (tree.disabledContextMenu) { if (tree.disabledContextMenu) {
cr.ui.contextMenuHandler.setContextMenu(this, tree.disabledContextMenu); cr.ui.contextMenuHandler.setContextMenu(this, tree.disabledContextMenu);
} }
......
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