Index: chrome/browser/resources/downloads/manager.js |
diff --git a/chrome/browser/resources/downloads/manager.js b/chrome/browser/resources/downloads/manager.js |
index 89a5aac0a88e7bfd1d37c5124b81f955ec92e433..7d18e571c326be800ad7fcdd98ff2051144eabce 100644 |
--- a/chrome/browser/resources/downloads/manager.js |
+++ b/chrome/browser/resources/downloads/manager.js |
@@ -102,7 +102,9 @@ cr.define('downloads', function() { |
/** @param {!downloads.Data} data Info about the item to update. */ |
updateItem: function(data) { |
- this.idMap_[data.id].render(data); |
+ var item = this.idMap_[data.id]; |
+ item.render(data); |
+ this.decorateItem_(item); |
}, |
/** |
@@ -110,22 +112,30 @@ cr.define('downloads', function() { |
* @private |
*/ |
rebuildFocusGrid_: function() { |
- var activeElement = document.activeElement; |
- |
/** @private {!cr.ui.FocusGrid} */ |
this.focusGrid_ = this.focusGrid_ || new cr.ui.FocusGrid(); |
this.focusGrid_.destroy(); |
+ this.items_.forEach(this.decorateItem_, this); |
+ }, |
- this.items_.forEach(function(item) { |
- downloads.FocusRow.decorate(item.view.node, item.view, this.node_); |
- var focusRow = assertInstanceof(item.view.node, downloads.FocusRow); |
+ /** |
+ * @param {!download.Item} item An item to decorate as a downloads.FocusRow. |
+ */ |
+ decorateItem_: function(item) { |
+ var activeElement = document.activeElement; |
+ |
+ downloads.FocusRow.decorate(item.view.node, item.view, this.node_); |
+ var focusRow = assertInstanceof(item.view.node, downloads.FocusRow); |
+ |
+ if (this.focusGrid_.rows.indexOf(focusRow) < 0) |
this.focusGrid_.addRow(focusRow); |
- // Focus the equivalent element in the focusRow because the active |
- // element may no longer be visible. |
- if (focusRow.contains(activeElement)) |
- focusRow.getEquivalentElement(activeElement).focus(); |
- }, this); |
+ // Focus the equivalent element in the focusRow because the active |
+ // element may no longer be visible. |
+ if (focusRow.focusableElements.indexOf(activeElement) >= 0 && |
hcarmona
2015/03/12 19:12:52
This should stay "if (focusRow.contains(activeElem
Dan Beam
2015/03/12 20:19:03
Fixed (differently though, see updated code)
|
+ activeElement != document.activeElement) { |
+ focusRow.getEquivalentElement(activeElement).focus(); |
+ } |
}, |
/** @return {number} The number of downloads shown on the page. */ |