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

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

Issue 2377193004: [DevTools] Rework some focus code. (Closed)
Patch Set: FocusRestorer Created 4 years, 3 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/View.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/View.js b/third_party/WebKit/Source/devtools/front_end/ui/View.js
index 6e910f7bb55c043878ffd0a7108bc4ccd0c9f955..3a3917091019917a83de21d871e58055edf90a53 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/View.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/View.js
@@ -435,6 +435,8 @@ WebInspector.ViewManager._ContainerWidget = function(view)
WebInspector.VBox.call(this);
this.element.classList.add("flex-auto", "view-container", "overflow-auto");
this._view = view;
+ this.element.tabIndex = 0;
+ this.setDefaultFocusedElement(this.element);
}
WebInspector.ViewManager._ContainerWidget.prototype = {
@@ -447,7 +449,14 @@ WebInspector.ViewManager._ContainerWidget.prototype = {
return this._materializePromise;
var promises = [];
promises.push(this._view.toolbarItems().then(WebInspector.ViewManager._populateToolbar.bind(WebInspector.ViewManager, this.element)));
- promises.push(this._view.widget().then(widget => widget.show(this.element)));
+ promises.push(this._view.widget().then(widget => {
+ // Move focus from |this| to loaded |widget| if any.
+ var shouldFocus = this.element.hasFocus();
+ this.setDefaultFocusedElement(null);
+ widget.show(this.element);
+ if (shouldFocus)
+ widget.focus();
+ }));
this._materializePromise = Promise.all(promises);
return this._materializePromise;
},
@@ -696,8 +705,8 @@ WebInspector.ViewManager._TabbedLocation.prototype = {
showView: function(view, insertBefore)
{
this.appendView(view, insertBefore);
- this._tabbedPane.focus();
this._tabbedPane.selectTab(view.viewId());
+ this._tabbedPane.focus();
return this._materializeWidget(view);
},
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js ('k') | third_party/WebKit/Source/devtools/front_end/ui/Widget.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698