Skip to content

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

@romgere

Description

@romgere

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions