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 ac5d84e9e41f8a39292094c146376dc7bdb2c14f..d260654e3f3ffdc49f4c8ffc1423900dbbbf7b80 100644 |
--- a/chrome/browser/resources/md_bookmarks/dialog_focus_manager.js |
+++ b/chrome/browser/resources/md_bookmarks/dialog_focus_manager.js |
@@ -44,6 +44,14 @@ cr.define('bookmarks', function() { |
showFn(); |
}, |
+ /** |
+ * 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_(); |
@@ -75,7 +83,7 @@ cr.define('bookmarks', function() { |
assert(this.dialogs_.delete(dialog)); |
// Focus the originally focused element if there are no more dialogs. |
- if (!this.dialogs_.size) |
+ if (!this.dialogs_.size && this.previousFocusElement_) |
this.previousFocusElement_.focus(); |
dialog.removeEventListener('close', closeListener); |