Index: chrome/browser/resources/md_bookmarks/dialog_focus_manager.js |
diff --git a/chrome/browser/resources/md_bookmarks/dialog_focus_manager.js b/chrome/browser/resources/md_bookmarks/dialog_focus_manager.js |
index 98c0fd34e84411460162132e3eb9ef549879f831..cad7d7ea17c230fe336855edcbe987524dcf5643 100644 |
--- a/chrome/browser/resources/md_bookmarks/dialog_focus_manager.js |
+++ b/chrome/browser/resources/md_bookmarks/dialog_focus_manager.js |
@@ -51,6 +51,14 @@ cr.define('bookmarks', function() { |
return this.dialogs_.size > 0; |
}, |
+ /** |
+ * Clears the stored focus element, so that focus does not restore when all |
+ * dialogs are closed. |
+ */ |
+ clearFocus: function() { |
+ this.previousFocusElement_ = null; |
+ }, |
+ |
/** @private */ |
updatePreviousFocus_: function() { |
this.previousFocusElement_ = this.getFocusedElement_(); |
@@ -82,7 +90,7 @@ cr.define('bookmarks', function() { |
assert(this.dialogs_.delete(dialog)); |
// Focus the originally focused element if there are no more dialogs. |
- if (!this.hasOpenDialog()) |
+ if (!this.hasOpenDialog() && this.previousFocusElement_) |
this.previousFocusElement_.focus(); |
dialog.removeEventListener('close', closeListener); |