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

Select is not properly reseted when selected is a promise

Open romgere opened this issue 4 years ago • 2 comments

Hi, I have an issue when selected is a promise when trying to clear the select.

Here is a minimal reproduction (base on master) :

<PowerSelect
  @selected={{this.selected}}
  @onChange={{this.change}}
  @options={{this.cities}}
  @allowClear={{true}}
  as |city|>
  {{city}}
</PowerSelect>

https://github.com/romgere/ember-power-select/blob/asyn_issue/tests/dummy/app/templates/playground.hbs

 cities = ['Barcelona', 'London', 'New York', 'Porto', 'Coruña', 'Kracow', 'Siena', 'Portland', 'Springfield', 'Tokio']

  @tracked _selected = undefined
  get selected() {
    let s = this._selected === undefined
      ? resolve(this.cities[2])
      : this._selected
    return s
  }

  set selected(v) {
    this._selected = v
  }

  @action
  change(v) {
    this.selected = v
  }

https://github.com/romgere/ember-power-select/blob/asyn_issue/tests/dummy/app/controllers/playground.js

& here is the behavior when trying to clear the select (with clear button, or by settings the value to null "externaly") : issue-power-select Select is not updated.

I didn't try, but I'm 100% sure it was working on previous power-select version

romgere avatar Oct 21 '21 07:10 romgere

I'm facing the same issue. Here is the version used: "ember-power-select": "~6.0.1",

aayousry avatar Feb 15 '23 19:02 aayousry

:up: me2 Resolved it temporarily by resetting the value via return this.selectedValue ?? Promise.resolve()

derrabauke avatar Feb 28 '23 15:02 derrabauke