Bug 189569 - Web Inspector: Opening inspector with a selected element might immediately scroll that element off screen in the DOM Tree outline
Summary: Web Inspector: Opening inspector with a selected element might immediately sc...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-09-12 17:00 PDT by Joseph Pecoraro
Modified: 2018-09-13 16:58 PDT (History)
8 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (2.60 KB, patch)
2018-09-12 17:01 PDT, Joseph Pecoraro
joepeck: review-
joepeck: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews106 for mac-sierra-wk2 (3.54 MB, application/zip)
2018-09-12 21:29 PDT, EWS Watchlist
no flags Details
[PATCH] Proposed Fix (1.68 KB, patch)
2018-09-13 10:24 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews122 for ios-simulator-wk2 (2.42 MB, application/zip)
2018-09-13 12:23 PDT, EWS Watchlist
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2018-09-12 17:00:13 PDT
Opening inspector with a selected element might immediately scroll that element off screen in the DOM Tree outline

Steps to Reproduce:
1. Open https://www.apple.com/iphone-xs/
2. Scroll down
3. Select some text
4. Context menu > Inspect Element
  => Web Inspector opens, but that element is not visible (you need to scroll down in the DOM Tree in the Elements tab)

Notes:
- Watching in slow motion, the tab opens, element is selected, then the sidebar opens, the tree lays out and the selected element is pushed down.
Comment 1 Joseph Pecoraro 2018-09-12 17:00:23 PDT
<rdar://problem/44397098>
Comment 2 Joseph Pecoraro 2018-09-12 17:01:32 PDT
Created attachment 349597 [details]
[PATCH] Proposed Fix

I want to live on this for a while to make sure it doesn't cause any unexpected problems.
Comment 3 Devin Rousso 2018-09-12 21:15:56 PDT
Comment on attachment 349597 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=349597&action=review

> Source/WebInspectorUI/UserInterface/Views/ElementsTabContentView.js:44
> +        WI.detailsSidebar.addEventListener(WI.Sidebar.Event.CollapsedStateDidChange, this._elementsTabDetailsSidebarCollapsedStateDidChange, this);

I think we might also want to re-scroll the node if the sidebar's width changes too, not just if it collapses.  You should be able to modify `WI.DOMTreeContentView.prototype.layout`:

        if (this.layoutReason === WI.View.LayoutReason.Resize)
            this._domTreeOutline.selectDOMNode(this._domTreeOutline.selectedDOMNode());
Comment 4 EWS Watchlist 2018-09-12 21:29:17 PDT Comment hidden (obsolete)
Comment 5 EWS Watchlist 2018-09-12 21:29:18 PDT Comment hidden (obsolete)
Comment 6 Joseph Pecoraro 2018-09-13 10:20:36 PDT
Comment on attachment 349597 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=349597&action=review

>> Source/WebInspectorUI/UserInterface/Views/ElementsTabContentView.js:44
>> +        WI.detailsSidebar.addEventListener(WI.Sidebar.Event.CollapsedStateDidChange, this._elementsTabDetailsSidebarCollapsedStateDidChange, this);
> 
> I think we might also want to re-scroll the node if the sidebar's width changes too, not just if it collapses.  You should be able to modify `WI.DOMTreeContentView.prototype.layout`:
> 
>         if (this.layoutReason === WI.View.LayoutReason.Resize)
>             this._domTreeOutline.selectDOMNode(this._domTreeOutline.selectedDOMNode());

Great idea!
Comment 7 Joseph Pecoraro 2018-09-13 10:24:27 PDT
Created attachment 349677 [details]
[PATCH] Proposed Fix
Comment 8 EWS Watchlist 2018-09-13 12:23:18 PDT Comment hidden (obsolete)
Comment 9 EWS Watchlist 2018-09-13 12:23:20 PDT Comment hidden (obsolete)
Comment 10 Devin Rousso 2018-09-13 16:33:00 PDT
Comment on attachment 349677 [details]
[PATCH] Proposed Fix

r=me
Comment 11 WebKit Commit Bot 2018-09-13 16:58:48 PDT
Comment on attachment 349677 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 349677

Committed r235996: <https://trac.webkit.org/changeset/235996>
Comment 12 WebKit Commit Bot 2018-09-13 16:58:50 PDT
All reviewed patches have been landed.  Closing bug.