Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

opened-changed overservers gets triggered twice #99

Description

@ktiedt

Due to iron-collapse also generating the same event, it bubbles up to the paper-submenu and triggers twice, and I am guessing due to event retargetting the target is set to paper-submenu each time...

We have to evaluate the event.path property to make sure we only listen to the actual submenu event. Below is the handler we use for on-opened-changed:

  /**
   * An observer that intercepts submenu open events and forces a subsequent
   * iron-collapse updateSize call to bypass a race condition in iron-collapse.
   * @param {!Object} evt The opened-changed event object.
   * @param {!Object} change The change record for the opened property.
   */
  ensureMenuOpens_: function(evt, change) {
    if (change.value) {
      var menu = evt.target;
      // event from iron-collapse will bubble up and trigger this twice, so if
      // path[0].tagName is not paper-submenu, we ignore this.
      if (evt.path[0].tagName.toLowerCase() == 'paper-submenu') {
        menu.async(function() {
          this.set('opened', true);
          this.$.collapse.updateSize('auto', true);
        }, 1);
      }
    }
  },

Note: Our need for this handler could be a side-effect of #88, after reading it, but I am not positive.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions