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

Unified Diff: chrome/browser/resources/md_bookmarks/command_manager.js

Issue 2940233003: MD Bookmarks: Lazily render dropdown menus (Closed)
Patch Set: Rebase Created 3 years, 6 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
Index: chrome/browser/resources/md_bookmarks/command_manager.js
diff --git a/chrome/browser/resources/md_bookmarks/command_manager.js b/chrome/browser/resources/md_bookmarks/command_manager.js
index 1fc42a70c685d5be5d35f6ac6765b6021f29f75a..95d77a6758bc4d4a67d12277a696c58ebf70ec48 100644
--- a/chrome/browser/resources/md_bookmarks/command_manager.js
+++ b/chrome/browser/resources/md_bookmarks/command_manager.js
@@ -106,8 +106,11 @@ cr.define('bookmarks', function() {
*/
openCommandMenuAtPosition: function(x, y, items) {
this.menuIds_ = items || this.getState().selection.items;
- /** @type {!CrActionMenuElement} */ (this.$.dropdown)
- .showAtPosition({top: y, left: x});
+ var dropdown =
+ /** @type {!CrActionMenuElement} */ (this.$.dropdown.get());
+ // Ensure that the menu is fully rendered before trying to position it.
+ Polymer.dom.flush();
+ dropdown.showAtPosition({top: y, left: x});
},
/**
@@ -117,12 +120,16 @@ cr.define('bookmarks', function() {
*/
openCommandMenuAtElement: function(target) {
this.menuIds_ = this.getState().selection.items;
- /** @type {!CrActionMenuElement} */ (this.$.dropdown).showAt(target);
+ var dropdown =
+ /** @type {!CrActionMenuElement} */ (this.$.dropdown.get());
+ // Ensure that the menu is fully rendered before trying to position it.
+ Polymer.dom.flush();
+ dropdown.showAt(target);
},
closeCommandMenu: function() {
this.menuIds_ = new Set();
- /** @type {!CrActionMenuElement} */ (this.$.dropdown).close();
+ /** @type {!CrActionMenuElement} */ (this.$.dropdown.get()).close();
},
////////////////////////////////////////////////////////////////////////////
@@ -457,7 +464,7 @@ cr.define('bookmarks', function() {
* @private
*/
onMenuMousedown_: function(e) {
- if (e.path[0] != this.$.dropdown)
+ if (e.path[0] != this.$.dropdown.getIfExists())
return;
this.closeCommandMenu();

Powered by Google App Engine
This is Rietveld 408576698