diegoles / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.ui.PopupMenu missing a touchstart event listener on the document #518

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
A popupmenu use both a blur event and a click event on the document to know 
when to hide the menu. In touch enabled devices we also need a touchstart event 
otherwise if an element decides not to be focused, the menu won't be hidden on 
click.

In addition, wouldn't it be better to add/remove events on show/hide to save 
resources. Another option is to have a menu manager that with one listener that 
is responsible to hide visible menus when needed. With the current 
implementation, if you have 10 popup menus, you have have 10 listeners on the 
document element that catch all events.

/** @override */
goog.ui.PopupMenu.prototype.enterDocument = function() {
  goog.ui.PopupMenu.superClass_.enterDocument.call(this);

  ...
  handler.listen(this.getDomHelper().getDocument(),
      goog.events.EventType.TOUCHSTART, this.onDocClick, true);

  ...
};

Thanks

Original issue reported on code.google.com by pablo.platt@gmail.com on 3 Dec 2012 at 1:57