Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Unified Diff: ui/webui/resources/js/cr/ui/focus_grid.js

Issue 1128953004: Fix regression where rows could become non-focusable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ab418899878dc30c8fa661f8c94d39ed8ad7fb07..ada2d2518a7b99748e0e0a14b5984be5454f5d8b 100644
--- a/ui/webui/resources/js/cr/ui/focus_grid.js
+++ b/ui/webui/resources/js/cr/ui/focus_grid.js
@@ -139,14 +139,39 @@ cr.define('cr.ui', function() {
},
/**
- * Add a FocusRow to this grid. This needs to be called AFTER adding columns
- * to the row. This is so that TAB focus can be properly enabled in the
- * columns.
+ * Add a FocusRow to this grid. Row is added at the end.
Dan Beam 2015/05/12 01:28:42 Adds |row| to the end of this grid.
hcarmona 2015/05/12 02:00:47 Done.
* @param {cr.ui.FocusRow} row The row that needs to be added to this grid.
*/
addRow: function(row) {
+ this.addRowBefore(row, null);
+ },
+
+ /**
+ * Add a FocusRow to this grid in order. Adds at the end if |nextRow| is
Dan Beam 2015/05/12 01:28:42 Add -> Adds
hcarmona 2015/05/12 02:00:47 Done.
+ * not in the list of rows.
+ * @param {cr.ui.FocusRow} row The row that needs to be added to this grid.
Dan Beam 2015/05/12 01:28:42 !cr.ui.FocusRow for |row|
hcarmona 2015/05/12 02:00:47 Done.
+ * @param {cr.ui.FocusRow} nextRow The row that should follow |row|.
+ */
+ addRowBefore: function(row, nextRow) {
row.delegate = row.delegate || this.delegate_;
- this.rows.push(row);
+
+ var nextRowIndex = this.rows.indexOf(nextRow);
+ if (nextRowIndex == -1) {
Dan Beam 2015/05/12 01:28:42 no curlies
hcarmona 2015/05/12 02:00:47 Done.
+ this.rows.push(row);
+ } else {
+ this.rows.splice(nextRowIndex, 0, row);
+ }
+ },
+
+ /**
+ * Removes a row from the focus row. No-op if row is not in the grid.
+ * @param {cr.ui.FocusRow} row The row that needs to be removed.
+ */
+ removeRow: function(row) {
+ var nextRowIndex = this.rows.indexOf(row);
+ if (nextRowIndex > -1) {
Dan Beam 2015/05/12 01:28:42 no curlies
hcarmona 2015/05/12 02:00:47 Done.
+ this.rows.splice(nextRowIndex, 1);
+ }
},
/**

Powered by Google App Engine
This is Rietveld 408576698