ember-power-select icon indicating copy to clipboard operation
ember-power-select copied to clipboard

Option to prevent bubbling when power-select is opened

Open artemgurzhii opened this issue 6 years ago • 1 comments

My use case

<div {{action 'openSomething'}}>
  <div {{action 'editMode' bubbles=false}}>Edit something</div>
  {{#power-select
    options=options
    selected=selected
    onchange=(action 'onchange')
  as |option|}}
    <span>{{option.name}}</span>
  {{/power-select}}
</div>

What I need - is to prevent openSomething action from firing, when I'm trying to open power-select menu.

This can be done by changing components/power-select.js#onopen action, with the following code

ember-power-select/addon/components/power-select.js

onOpen(_, e, options) {
  // Some code

  if (options.bubbles === false) {
    e.preventDefault();
  }

  // Rest of the code
}

and use it like this

myapp/component/open-something.js

onopen() {
  this.performSomeCustomLogic();
  this._super(...arguments, { bubbles: false });
}

I can make a PR for this if you find this idea reasonable. And thank you for the awesome addon)

artemgurzhii avatar Mar 06 '18 19:03 artemgurzhii

@cibernox This would be very useful, any updates on it?

Glarregle avatar Jul 26 '19 22:07 Glarregle