Bug 1374784 - Unable to use keyboard to navigate cookies r?gl draft
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Tue, 20 Jun 2017 21:37:07 +0100
changeset 598097 f954e1f819c0aa8d41c38b2805615c55cbd592a2
parent 597455 464b2a3c25aa1065760d9ecbb0870bca4a66c62e
child 598130 0c1a0ce3e516e895117a3fddf14fa00c08d4d46f
push id65140
push userbmo:mratcliffe@mozilla.com
push dateWed, 21 Jun 2017 12:11:26 +0000
reviewersgl
bugs1374784
milestone56.0a1
Bug 1374784 - Unable to use keyboard to navigate cookies r?gl Keyboard navigation was broken because we introduced private columns that are never displayed (for compound primary keys) and were not equipped to deal with hidden key columns. This change gets the first visible column, whether it is private or not so that we no longer have to worry about hidden key columns. The small change to the keyboard test ensures that the private column is hidden so the test will fail if this feature is broken again. MozReview-Commit-ID: IB7efHsflGU
devtools/client/shared/widgets/TableWidget.js
devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js
--- a/devtools/client/shared/widgets/TableWidget.js
+++ b/devtools/client/shared/widgets/TableWidget.js
@@ -180,28 +180,46 @@ TableWidget.prototype = {
   get selectedIndex() {
     return this.columns.get(this.uniqueId).selectedIndex;
   },
 
   /**
    * Returns the index of the selected row disregarding hidden rows.
    */
   get visibleSelectedIndex() {
-    let cells = this.columns.get(this.uniqueId).visibleCellNodes;
+    let column = this.firstVisibleColumn;
+    let cells = column.visibleCellNodes;
 
     for (let i = 0; i < cells.length; i++) {
       if (cells[i].classList.contains("theme-selected")) {
         return i;
       }
     }
 
     return -1;
   },
 
   /**
+   * Returns the first visible column.
+   */
+  get firstVisibleColumn() {
+    for (let column of this.columns.values()) {
+      if (column._private) {
+        continue;
+      }
+
+      if (column.column.clientHeight > 0) {
+        return column;
+      }
+    }
+
+    return null;
+  },
+
+  /**
    * returns all editable columns.
    */
   get editableColumns() {
     let filter = columns => {
       columns = [...columns].filter(col => {
         if (col.clientWidth === 0) {
           return false;
         }
--- a/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js
+++ b/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js
@@ -4,16 +4,17 @@
 
 // Basic test to check the editing of cookies with the keyboard.
 
 "use strict";
 
 add_task(function* () {
   yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies.html");
   showAllColumns(true);
+  showColumn("uniqueKey", false);
 
   let id = getCookieId("test4", "test1.example.org", "/browser");
   yield startCellEdit(id, "name");
   yield typeWithTerminator("test6", "VK_TAB");
   yield typeWithTerminator(".example.org", "VK_TAB");
   yield typeWithTerminator("/", "VK_TAB");
   yield typeWithTerminator("Tue, 25 Dec 2040 12:00:00 GMT", "VK_TAB");
   yield typeWithTerminator("test6value", "VK_TAB");