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

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

Issue 2510883002: DevTools: all swatches should have a default focused element (Closed)
Patch Set: ac Created 4 years, 1 month 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/Popover.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/Popover.js b/third_party/WebKit/Source/devtools/front_end/ui/Popover.js
index 7d27e2a0479f642d69ae58ead704421972410b3e..55b6dcaff49a1e59eaa75cead14e657a86d6a7fe 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/Popover.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/Popover.js
@@ -83,8 +83,11 @@ UI.Popover = class extends UI.Widget {
this._contentElement = contentElement;
// This should not happen, but we hide previous popup to be on the safe side.
- if (UI.Popover._popover)
+ var restoreFocus;
+ if (UI.Popover._popover) {
+ restoreFocus = UI.Popover._popover.hasFocus();
UI.Popover._popover.hide();
+ }
UI.Popover._popover = this;
var document = anchor instanceof Element ? anchor.ownerDocument : contentElement.ownerDocument;
@@ -99,10 +102,15 @@ UI.Popover = class extends UI.Widget {
document.body.appendChild(this._containerElement);
super.show(this._containerElement);
- if (view)
+ if (view) {
view.show(this._contentDiv);
- else
+ if (restoreFocus)
+ view.focus();
+ } else {
this._contentDiv.appendChild(this._contentElement);
+ if (restoreFocus)
+ this._contentElement.focus();
+ }
this.positionElement(anchor, this._preferredWidth, this._preferredHeight, arrowDirection);

Powered by Google App Engine
This is Rietveld 408576698