Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select is not properly reseted when selected is a promise #1467

Open
romgere opened this issue Oct 21, 2021 · 2 comments · Fixed by ultish/ember-power-select#1
Open

Select is not properly reseted when selected is a promise #1467

romgere opened this issue Oct 21, 2021 · 2 comments · Fixed by ultish/ember-power-select#1

Comments

@romgere
Copy link

romgere commented Oct 21, 2021

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

@aayousry
Copy link

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

@derrabauke
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants