cibernox / ember-power-select-typeahead

Typeahead component built on top of ember-power-select
MIT License
37 stars 57 forks source link

Initial "selected" value does not populate the input #132

Open christophersansone opened 1 year ago

christophersansone commented 1 year ago

When the component is pre-populated with a selected value upon creation, the value is not presented in the input. It is presented in the drop-down, but not the input. The only way to get the value to show is to select another option.

This use case is helpful when the developer wants to present a default value to the user, or in the case where it is being used as a data-driven property of an existing object.

To reproduce:

import Component from '@glimmer/component';
import { tracking } from '@glimmer/tracking';

export default class TestComponent extends Component {
  options = [ 'one', 'two', 'three', 'four', 'five' ];

  @tracked selected = 'three';
}
<PowerSelectTypeahead @options={{this.options}} @selected={{this.selected}} @onChange={{action (mut this.selected)}} />

Expected behavior: The input text should show 'three'.

Actual behavior: The input text is empty.