Web Inspector: Elements tab: arrow key after undoing a DOM node delete selects the...
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2018 00:46:10 +0000 (00:46 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2018 00:46:10 +0000 (00:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192871
<rdar://problem/46849060>

Reviewed by Devin Rousso.

Undoing a DOM node removal reinserts the node into the DOMTreeOutline.
When the reinserted node precedes the selected node in the tree, the
SelectionController should update `_lastSelectedIndex`.

* UserInterface/Controllers/SelectionController.js:
(WI.SelectionController.prototype.didInsertItem):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239405 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/SelectionController.js
Source/WebInspectorUI/UserInterface/Views/TreeOutline.js

index 2bf804c..7b97204 100644 (file)
@@ -1,3 +1,18 @@
+2018-12-19  Matt Baker  <mattbaker@apple.com>
+
+        Web Inspector: Elements tab: arrow key after undoing a DOM node delete selects the wrong element
+        https://bugs.webkit.org/show_bug.cgi?id=192871
+        <rdar://problem/46849060>
+
+        Reviewed by Devin Rousso.
+
+        Undoing a DOM node removal reinserts the node into the DOMTreeOutline.
+        When the reinserted node precedes the selected node in the tree, the
+        SelectionController should update `_lastSelectedIndex`.
+
+        * UserInterface/Controllers/SelectionController.js:
+        (WI.SelectionController.prototype.didInsertItem):
+
 2018-12-19  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Audit: provide localization support for % pass display
index 7066a3d..b65f9f0 100644 (file)
@@ -212,6 +212,11 @@ WI.SelectionController = class SelectionController extends WI.Object
 
             current = this._selectedIndexes.indexLessThan(current);
         }
+
+        if (this._lastSelectedIndex >= index)
+            this._lastSelectedIndex += 1;
+        if (this._shiftAnchorIndex >= index)
+            this._shiftAnchorIndex += 1;
     }
 
     didRemoveItems(indexes)
index cc8bb2d..22840a1 100644 (file)
@@ -406,8 +406,10 @@ WI.TreeOutline = class TreeOutline extends WI.Object
         this._cachedNumberOfDescendents++;
 
         let index = this._indexOfTreeElement(element);
-        if (index >= 0)
+        if (index >= 0) {
+            console.assert(!element.selected, "TreeElement should not be selected before being inserted.");
             this._selectionController.didInsertItem(index);
+        }
     }
 
     _forgetTreeElement(element)