Bug 208364 - REGRESSION(r257380): Web Inspector: deleting node causes TreeOutline to lose focus
Summary: REGRESSION(r257380): Web Inspector: deleting node causes TreeOutline to lose ...
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: Nikita Vasilyev
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-02-27 17:54 PST by Nikita Vasilyev
Modified: 2020-03-16 18:01 PDT (History)
4 users (show)

See Also:


Attachments
Patch (3.19 KB, patch)
2020-02-28 17:55 PST, Nikita Vasilyev
no flags Details | Formatted Diff | Diff
[Video] With patch applied (4.08 MB, video/quicktime)
2020-02-28 18:00 PST, Nikita Vasilyev
no flags Details
Patch (1.53 KB, patch)
2020-03-13 12:49 PDT, Nikita Vasilyev
hi: review+
Details | Formatted Diff | Diff
Patch (1.96 KB, patch)
2020-03-16 17:12 PDT, Nikita Vasilyev
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2020-02-27 17:54:48 PST
# STEPS TO REPRODUCE:
1. inspect any page
2. go to the Elements Tab
3. select any node
4. delete ⌫ that node
=> selection moves to the previous node, but in an unfocused state, so you can't use the arrow keys for further navigation

# STEPS TO REPRODUCE:
1. inspect any page
2. go to the Sources Tab
3. add a few JavaScript breakpoints to any file
4. select one of the JavaScript breakpoints
5. delete ⌫ that JavaScript breakpoint
=> selection moves to the previous JavaScript breakpoint, but in an unfocused state, so you can't reselect the breakpoint in order to re-enable keyboard navigation

Regressed in r257380.
Comment 1 Radar WebKit Bug Importer 2020-02-27 17:54:57 PST
<rdar://problem/59871772>
Comment 2 Nikita Vasilyev 2020-02-28 17:55:50 PST
Created attachment 392041 [details]
Patch
Comment 3 Nikita Vasilyev 2020-02-28 18:00:32 PST
Created attachment 392042 [details]
[Video] With patch applied
Comment 4 Devin Rousso 2020-03-05 15:49:55 PST
Comment on attachment 392041 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/TreeElement.js:533
> +        else if (treeOutline.element.contains(document.activeElement)) {

It seems really odd that `omitFocus === true` can still change the focus.

> Source/WebInspectorUI/UserInterface/Views/TreeElement.js:-535
> -        // Focusing on another node may detach "this" from tree.
> -        let treeOutline = this.treeOutline;
> -        if (!treeOutline)
> -            return;

I don't think this should be removed/moved.  I think the original intention of this comment and check was that calling the `.focus()` above may be handled by an event listener, which could remove `this` from `this.treeOutline`, so we need to check that we're still attached to a tree before selecting.
Comment 5 Nikita Vasilyev 2020-03-05 16:11:31 PST
Comment on attachment 392041 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Views/TreeElement.js:533
>> +        else if (treeOutline.element.contains(document.activeElement)) {
> 
> It seems really odd that `omitFocus === true` can still change the focus.

It does seem a bit odd. I don't know a better alternative. I can rename it to something like `omitForceFocus`.

I tried removing omitFocus parameter entirely. That was quite a rabbit holes — after a day of working on it I only introduced several other regressions.

>> Source/WebInspectorUI/UserInterface/Views/TreeElement.js:-535
>> -            return;
> 
> I don't think this should be removed/moved.  I think the original intention of this comment and check was that calling the `.focus()` above may be handled by an event listener, which could remove `this` from `this.treeOutline`, so we need to check that we're still attached to a tree before selecting.

It doesn't seem to make a difference. I can keep this as-is.
Comment 6 Nikita Vasilyev 2020-03-13 12:49:13 PDT
Created attachment 393520 [details]
Patch

I removed the drive-by change.
Comment 7 Devin Rousso 2020-03-16 15:47:48 PDT
Comment on attachment 393520 [details]
Patch

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

r=me, nice fix.

> Source/WebInspectorUI/UserInterface/Views/TreeElement.js:528
> +        else if (this.treeOutline?.element.contains(document.activeElement)) {

It's unnecessary to `?.element` because we know that `this.treeOutline` is truthy because of the early return at the beginning of this function.

Also, I'd be fine if you moved the `let treeOutline = this.treeOutline;` to the beginning of this function so that we don't have to continue referencing it via `this.treeOutline`.
Comment 8 Nikita Vasilyev 2020-03-16 17:12:36 PDT
Created attachment 393711 [details]
Patch
Comment 9 WebKit Commit Bot 2020-03-16 18:01:21 PDT
Comment on attachment 393711 [details]
Patch

Clearing flags on attachment: 393711

Committed r258536: <https://trac.webkit.org/changeset/258536>
Comment 10 WebKit Commit Bot 2020-03-16 18:01:23 PDT
All reviewed patches have been landed.  Closing bug.