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; |