Index: ui/webui/resources/js/cr/ui/focus_grid.js |
diff --git a/ui/webui/resources/js/cr/ui/focus_grid.js b/ui/webui/resources/js/cr/ui/focus_grid.js |
index 40c782e037b3139b6df3dfd7da4b62093373bb37..000fb051966f5438fe1bdd2eb3ed3347fa3fdae3 100644 |
--- a/ui/webui/resources/js/cr/ui/focus_grid.js |
+++ b/ui/webui/resources/js/cr/ui/focus_grid.js |
@@ -146,8 +146,11 @@ cr.define('cr.ui', function() { |
/** |
* Makes sure that at least one row is active. Should be called once, after |
* adding all rows to FocusGrid. |
+ * @param {number=} preferredRow The row to select if no other row is |
+ * active. Selects the first item if this is beyond the range of the |
+ * grid. |
*/ |
- ensureRowActive: function() { |
+ ensureRowActive: function(preferredRow) { |
if (this.rows.length == 0) |
return; |
@@ -156,7 +159,7 @@ cr.define('cr.ui', function() { |
return; |
} |
- this.rows[0].makeActive(true); |
+ (this.rows[preferredRow || 0] || this.rows[0]).makeActive(true); |
}, |
}; |