Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/Dialog.js

Issue 2016963002: DevTools: rework focus logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove stray newline Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js b/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
index dda2f68041abcedc3f5136dfc8828851b4b2f6b5..a15b39a0ccea3dff0f1e678ed7805db4dbfe87d2 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
@@ -73,7 +73,10 @@ WebInspector.Dialog.prototype = {
this._glassPane = new WebInspector.GlassPane(document, this._dimmed);
this._glassPane.element.addEventListener("click", this._onGlassPaneClick.bind(this), false);
- WebInspector.GlassPane.DefaultFocusedViewStack.push(this);
+
+ // When a dialog closes, focus should be restored to the previous focused element when
+ // possible, otherwise the default inspector view element.
+ WebInspector.Dialog._previousFocusedElement = WebInspector.currentFocusElement() || WebInspector.Dialog._modalHostView.defaultFocusedElement();
WebInspector.Widget.prototype.show.call(this, this._glassPane.element);
@@ -88,10 +91,13 @@ WebInspector.Dialog.prototype = {
{
WebInspector.Widget.prototype.detach.call(this);
- WebInspector.GlassPane.DefaultFocusedViewStack.pop();
this._glassPane.dispose();
delete this._glassPane;
+ if (WebInspector.Dialog._previousFocusedElement)
+ WebInspector.Dialog._previousFocusedElement.focus();
+ delete WebInspector.Dialog._previousFocusedElement;
+
this._restoreTabIndexOnElements();
delete WebInspector.Dialog._instance;
@@ -251,6 +257,9 @@ WebInspector.Dialog.prototype = {
__proto__: WebInspector.Widget.prototype
};
+/** @type {?Element} */
+WebInspector.Dialog._previousFocusedElement = null;
+
/** @type {?WebInspector.Widget} */
WebInspector.Dialog._modalHostView = null;

Powered by Google App Engine
This is Rietveld 408576698