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

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

Issue 2829683003: DevTools: Don't lose focus when interacting with ListWidget (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/ui/ListWidget.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/ListWidget.js b/third_party/WebKit/Source/devtools/front_end/ui/ListWidget.js
index 6a3a19e79b0779cf4c49ae3b795c79aecddc3c12..d3b487982c06bc623ffc33ddaade6b10cfe717bf 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/ListWidget.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/ListWidget.js
@@ -14,6 +14,7 @@ UI.ListWidget = class extends UI.VBox {
this._delegate = delegate;
this._list = this.contentElement.createChild('div', 'list');
+ this.element.tabIndex = -1;
/** @type {?UI.ListWidget.Editor} */
this._editor = null;
@@ -25,6 +26,9 @@ UI.ListWidget = class extends UI.VBox {
/** @type {?Element} */
this._emptyPlaceholder = null;
+ /** @type {?Element} */
+ this._previousFocusedElement = null;
einbinder 2017/04/19 17:02:09 Can't use focus restorer, because we don't necessa
dgozman 2017/04/19 19:59:34 Could you please describe in more details?
einbinder 2017/04/20 16:35:26 The list doesn't need to steal focus, it is up to
+
this.clear();
}
@@ -144,6 +148,7 @@ UI.ListWidget = class extends UI.VBox {
*/
function onRemoveClicked() {
var index = this._elements.indexOf(element);
+ this.element.focus();
einbinder 2017/04/19 17:02:09 When a remove button is clicked, I don't have a go
this._delegate.removeItemRequested(this._items[index], index);
}
}
@@ -176,6 +181,7 @@ UI.ListWidget = class extends UI.VBox {
return;
this._stopEditing();
+ this._previousFocusedElement = this.element.ownerDocument.deepActiveElement();
this._list.classList.add('list-editing');
this._editItem = item;
@@ -202,6 +208,7 @@ UI.ListWidget = class extends UI.VBox {
_stopEditing() {
this._list.classList.remove('list-editing');
+ var hadFocus = this._editor && this._editor.element.hasFocus();
if (this._editElement)
this._editElement.classList.remove('hidden');
if (this._editor && this._editor.element.parentElement)
@@ -211,6 +218,9 @@ UI.ListWidget = class extends UI.VBox {
this._editItem = null;
this._editElement = null;
this._updatePlaceholder();
+ if (this._previousFocusedElement && hadFocus)
+ this._previousFocusedElement.focus();
+ this._previousFocusedElement = null;
}
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698