Changeset 259277 in webkit


Ignore:
Timestamp:
Mar 30, 2020, 8:32:05 PM (5 years ago)
Author:
Nikita Vasilyev
Message:

Web Inspector: the Dock Side navigation item is automatically focused when Web Inspector is opened detached, preventing any global spacebar shortcuts from working
https://bugs.webkit.org/show_bug.cgi?id=209760

Reviewed by Devin Rousso.

When undocking, Web Inspector focuses on the first visible focusable element. I don't know why.
This patch restores the focus to the previously focused element.

  • UserInterface/Base/Main.js:
Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r259274 r259277  
     12020-03-30  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: the Dock Side navigation item is automatically focused when Web Inspector is opened detached, preventing any global spacebar shortcuts from working
     4        https://bugs.webkit.org/show_bug.cgi?id=209760
     5
     6        Reviewed by Devin Rousso.
     7
     8        When undocking, Web Inspector focuses on the first visible focusable element. I don't know why.
     9        This patch restores the focus to the previously focused element.
     10
     11        * UserInterface/Base/Main.js:
     12
    1132020-03-30  Devin Rousso  <drousso@apple.com>
    214
  • trunk/Source/WebInspectorUI/UserInterface/Base/Main.js

    r259274 r259277  
    902902    if (!WI.dockedConfigurationSupportsSplitContentBrowser() && !WI.doesCurrentTabSupportSplitContentBrowser())
    903903        WI.hideSplitConsole();
     904
     905    if (side === WI.DockConfiguration.Undocked && WI.Platform.name === "mac") {
     906        // When undocking, the first visible focusable element steals focus. Undo this.
     907        document.body.addEventListener("focusin", function(event) {
     908            let firstFocusableElement = document.querySelector("[tabindex='0']:not(.hidden)");
     909            if (firstFocusableElement === event.target) {
     910                if (WI.previousFocusElement)
     911                    WI.previousFocusElement.focus();
     912                else
     913                    event.target.blur();
     914            }
     915        }, {once: true, capture: true});
     916    }
    904917};
    905918
Note: See TracChangeset for help on using the changeset viewer.