vendredi 26 juillet 2019

How to open and close Ember Power Select from outside

I'm aware of this question, but is not complete. I want to open and close the dropdown from outside.

I can dispatch a mousedown event when click on my wrapper component, so ember-power-select trigger opens!. But then if I click again it doesn't close. More precisely, it closes and opens again rapidly.

My assumption is the component is listening blur event to get closed, and then the mousedown arrives again and open the trigger.

Has anyone managed to get this to work? or an alternative?? I'm quite lost :)

Thanks for the help!

wrapper-component.js 

  didInsertElement() {

    this._super(...arguments);
    this.element.addEventListener('mousedown', (event) => {
      event.stopPropagation();
      const eventedElement = this.element.querySelector('.ember-power-select-trigger');
      const mouseDownEvent = new MouseEvent('mousedown');
      eventedElement.dispatchEvent(mouseDownEvent);
    });

  },





Aucun commentaire:

Enregistrer un commentaire