ember-power-select
ember-power-select copied to clipboard
Manually close dropdown?
Hey!, thanks for the great work here :)
Is there a way of closing the dropdown from the outside? I'm trying to open/close the dropdown from a wrapper component.
I can open it dispatching a mousedown
event, but closing it is not possible. When the second mousedown
event is triggered the dropdown is first rapidly closed and then opened again. Is this intermediate closing caused by blur
event? I didn't get any output when debugging onBlur
action/event.
Thanks!
@Glarregle dispatching a mousedown from the outside works, but there's also another way.
The select has a registerAPI
property in the component that will be invoked when the component is instantiated and also on every internal state change. If you get hold of a reference to that object you can use it to control the select remotely from the outisde. Example:
<PowerSelect @selected={{selected}} @onChange={{action (mut selected)}} @registerAPI={{action (mut selectRemoteControl)}} as |opt|>
{{opt}}
</PowerSelect>
Then you can, from your code, do something like:
onSomeOtherButtonClick() {
this.selectRemoteControl.actions.close()
}