Commit 91eac2e6 authored by Esmael El-Moslimany's avatar Esmael El-Moslimany Committed by Commit Bot

Downloads WebUI: fix index out of range when moving focus after remove

Bug: 966300
Change-Id: I4106b1d83ed27574cdb8b6257ffbc9973736634c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626677Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Commit-Queue: Esmael El-Moslimany <aee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662895}
parent 44087d2a
...@@ -267,9 +267,10 @@ cr.define('downloads', function() { ...@@ -267,9 +267,10 @@ cr.define('downloads', function() {
}]); }]);
if (this.restoreFocusAfterRemove_) { if (this.restoreFocusAfterRemove_) {
this.restoreFocusAfterRemove_ = false; this.restoreFocusAfterRemove_ = false;
if (this.items_.length > 0) { const focusIndex = Math.min(this.items_.length - 1, index);
if (focusIndex >= 0) {
setTimeout(() => { setTimeout(() => {
this.$.downloadsList.focusItem(index); this.$.downloadsList.focusItem(focusIndex);
const item = getDeepActiveElement(); const item = getDeepActiveElement();
if (item) { if (item) {
item.focusOnRemoveButton(); item.focusOnRemoveButton();
......
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