Permalink
Browse files

bug: MaterialMenu couldn't always find it's 'for'-part

  • Loading branch information...
MikeMitterer committed Mar 9, 2017
1 parent cb33a80 commit 2812d7c179c9145385d3703b0df097bc90bda63f
Showing with 13 additions and 15 deletions.
  1. +12 −14 lib/src/components/MaterialMenu.dart
  2. +1 −1 lib/src/grinder/src/samples.dart
@@ -174,7 +174,7 @@ class MaterialMenu extends MdlComponent {
//- private -----------------------------------------------------------------------------------
void _init() {
_logger.fine("MaterialMenu - init");
_logger.info("MaterialMenu - init");
if (element != null) {
// Create container for the menu.
@@ -268,7 +268,7 @@ class MaterialMenu extends MdlComponent {
_logger.fine("forElId $forElId");
dom.Element forEl = null;
//dom.Element forEl = null;
if (forElId != null) {
void _addEventListeners(final dom.HtmlElement forEl) {
@@ -278,22 +278,20 @@ class MaterialMenu extends MdlComponent {
_forElement = forEl;
// .addEventListener('click', -> .onClick.listen(<MouseEvent>);
forEl.onClick.listen( _handleForClick );
forEl.onKeyDown.listen( _handleForKeyboardEvent );
eventStreams.add(
forEl.onClick.listen( _handleForClick ));
eventStreams.add(
forEl.onKeyDown.listen( _handleForKeyboardEvent ));
}
}
// getElementById is OK here! element.querySelector not possible!
forEl = dom.document.getElementById(forElId);
if(forEl != null) {
_addEventListeners(forEl);
} else {
// forEl was not found but maybe just because it takes a while for the DOM
// to recognize it... so we wait 50ms
new Future.delayed(new Duration(milliseconds: 50),() {
_addEventListeners(dom.document.getElementById(forElId));
});
}
// Also getElementById is slow - so we wait a few ms
new Future.delayed(new Duration(milliseconds: 100),() {
_addEventListeners(dom.document.getElementById(forElId));
_logger.info("_addEventListeners $forElId");
});
}
}
@@ -168,7 +168,7 @@ void createSampleList() {
samples.add(new Sample("nav-pills", Type.Dart, hasOwnDemoHtml: true));
samples.add(new Sample("notification", Type.Dart, hasOwnDartMain: true, hasOwnDemoHtml: true));
samples.add(new Sample("panel", Type.Dart, hasOwnDemoHtml: true));
samples.add(new Sample("snackbar", Type.Dart, hasOwnDartMain: true, hasOwnDemoHtml: true));
samples.add(new Sample("snackbar", Type.Dart, hasOwnDartMain: true, hasOwnDemoHtml: true, hasOwnPubSpec: true));
// MDL/Dart old
samples.add(new Sample("icons",Type.DartOld, hasScript: false, hasDemoHtml: false, hasDemoCss: false));

0 comments on commit 2812d7c

Please sign in to comment.