Title: [259277] trunk/Source/WebInspectorUI
Revision
259277
Author
nvasil...@apple.com
Date
2020-03-30 20:32:05 -0700 (Mon, 30 Mar 2020)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (259276 => 259277)


--- trunk/Source/WebInspectorUI/ChangeLog	2020-03-31 03:12:12 UTC (rev 259276)
+++ trunk/Source/WebInspectorUI/ChangeLog	2020-03-31 03:32:05 UTC (rev 259277)
@@ -1,3 +1,15 @@
+2020-03-30  Nikita Vasilyev  <nvasil...@apple.com>
+
+        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:
+
 2020-03-30  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: REGRESSION(r259101): items in the contextmenu of the tab bar don't have any text

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (259276 => 259277)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2020-03-31 03:12:12 UTC (rev 259276)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2020-03-31 03:32:05 UTC (rev 259277)
@@ -901,6 +901,19 @@
 
     if (!WI.dockedConfigurationSupportsSplitContentBrowser() && !WI.doesCurrentTabSupportSplitContentBrowser())
         WI.hideSplitConsole();
+
+    if (side === WI.DockConfiguration.Undocked && WI.Platform.name === "mac") {
+        // When undocking, the first visible focusable element steals focus. Undo this.
+        document.body.addEventListener("focusin", function(event) {
+            let firstFocusableElement = document.querySelector("[tabindex='0']:not(.hidden)");
+            if (firstFocusableElement === event.target) {
+                if (WI.previousFocusElement)
+                    WI.previousFocusElement.focus();
+                else
+                    event.target.blur();
+            }
+        }, {once: true, capture: true});
+    }
 };
 
 WI.resizeDockedFrameMouseDown = function(event)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to