Title: [238139] trunk/Source/WebInspectorUI
Revision
238139
Author
[email protected]
Date
2018-11-13 11:41:39 -0800 (Tue, 13 Nov 2018)

Log Message

Web Inspector: Table with no selection should select the first/last row on down/up arrow key
https://bugs.webkit.org/show_bug.cgi?id=190100
<rdar://problem/44879243>

Reviewed by Devin Rousso.

Pressing the up or down arrow key when nothing is selected should select
the last or first row, respectively. After selecting the row make sure
it is visible by calling the new Table method `revealRow`.

* UserInterface/Views/Table.js:
(WI.Table.prototype.revealRow):
(WI.Table.prototype._handleKeyDown):
(WI.Table.prototype._selectRowsFromArrowKey):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (238138 => 238139)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-11-13 18:44:25 UTC (rev 238138)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-11-13 19:41:39 UTC (rev 238139)
@@ -1,3 +1,20 @@
+2018-11-13  Matt Baker  <[email protected]>
+
+        Web Inspector: Table with no selection should select the first/last row on down/up arrow key
+        https://bugs.webkit.org/show_bug.cgi?id=190100
+        <rdar://problem/44879243>
+
+        Reviewed by Devin Rousso.
+
+        Pressing the up or down arrow key when nothing is selected should select
+        the last or first row, respectively. After selecting the row make sure
+        it is visible by calling the new Table method `revealRow`.
+
+        * UserInterface/Views/Table.js:
+        (WI.Table.prototype.revealRow):
+        (WI.Table.prototype._handleKeyDown):
+        (WI.Table.prototype._selectRowsFromArrowKey):
+
 2018-11-13  Nikita Vasilyev  <[email protected]>
 
         Web Inspector: Styles: Command-A should select all properties

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Table.js (238138 => 238139)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Table.js	2018-11-13 18:44:25 UTC (rev 238138)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Table.js	2018-11-13 19:41:39 UTC (rev 238139)
@@ -435,6 +435,27 @@
         this._removeRows(oldSelectedRows);
     }
 
+    revealRow(rowIndex)
+    {
+        console.assert(rowIndex >= 0 && rowIndex < this.numberOfRows);
+        if (rowIndex < 0 || rowIndex >= this.numberOfRows)
+            return;
+
+        // Force our own scroll update because we may have scrolled.
+        this._cachedScrollTop = NaN;
+
+        if (this._isRowVisible(rowIndex)) {
+            let row = this._cachedRows.get(rowIndex);
+            console.assert(row, "Visible rows should always be in the cache.");
+            if (row)
+                row.scrollIntoViewIfNeeded(false);
+            this.needsLayout();
+        } else {
+            this._scrollContainerElement.scrollTop = rowIndex * this._rowHeight;
+            this.updateLayout();
+        }
+    }
+
     columnWithIdentifier(identifier)
     {
         return this._columnSpecs.get(identifier);
@@ -1281,9 +1302,6 @@
         if (!this.numberOfRows)
             return;
 
-        if (!this._isRowVisible(this._selectedRowIndex))
-            return;
-
         if (event.metaKey || event.ctrlKey)
             return;
 
@@ -1290,14 +1308,8 @@
         if (event.keyIdentifier === "Up" || event.keyIdentifier === "Down") {
             this._selectRowsFromArrowKey(event.keyIdentifier === "Up", event.shiftKey);
 
-            let row = this._cachedRows.get(this._selectedRowIndex);
-            console.assert(row, "Moving up or down by one should always find a cached row since it is within the overflow bounds.");
-            row.scrollIntoViewIfNeeded(false);
+            this.revealRow(this._selectedRowIndex);
 
-            // Force our own scroll update because we may have scrolled.
-            this._cachedScrollTop = NaN;
-            this.needsLayout();
-
             event.preventDefault();
             event.stopPropagation();
         }
@@ -1305,6 +1317,12 @@
 
     _selectRowsFromArrowKey(goingUp, shiftKey)
     {
+        if (!this._selectedRows.size) {
+            let rowIndex = goingUp ? this.numberOfRows - 1 : 0;
+            this.selectRow(rowIndex);
+            return;
+        }
+
         let rowIncrement = goingUp ? -1 : 1;
         let rowIndex = this._selectedRowIndex + rowIncrement;
         if (rowIndex < 0 || rowIndex >= this.numberOfRows)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to