Index: chrome/browser/resources/options/inline_editable_list.js |
diff --git a/chrome/browser/resources/options/inline_editable_list.js b/chrome/browser/resources/options/inline_editable_list.js |
index 1c94a8d200b0ddd512a895a21852ded314c8874d..c071ff863a0d47255dda3919e13bbbd0b0142b77 100644 |
--- a/chrome/browser/resources/options/inline_editable_list.js |
+++ b/chrome/browser/resources/options/inline_editable_list.js |
@@ -72,8 +72,8 @@ cr.define('options', function() { |
DeletableItem.prototype.decorate.call(this); |
this.editFields_ = []; |
- this.addEventListener('mousedown', this.handleMouseDown_.bind(this)); |
- this.addEventListener('keydown', this.handleKeyDown_.bind(this)); |
+ this.addEventListener('mousedown', this.handleMouseDown_); |
+ this.addEventListener('keydown', this.handleKeyDown_); |
this.addEventListener('leadChange', this.handleLeadChange_); |
}, |
@@ -328,6 +328,21 @@ cr.define('options', function() { |
}, |
}; |
+ /** |
+ * Takes care of committing changes to inline editable list items when the |
+ * window loses focus. |
+ */ |
+ function handleWindowBlurs() { |
+ window.addEventListener('blur', function(e) { |
+ var itemAncestor = findAncestor(document.activeElement, function(node) { |
+ return node instanceof InlineEditableItem; |
+ }); |
+ if (itemAncestor); |
+ document.activeElement.blur(); |
+ }); |
+ } |
+ handleWindowBlurs(); |
+ |
var InlineEditableItemList = cr.ui.define('list'); |
InlineEditableItemList.prototype = { |