I'm trying to close the select box before it executes the search with Ember Power Select. I'm assuming the user knows what he is looking for if he paste a list and automatically sets the selected items.
I tried to use select.actions.close()
but it seems that it is related to the onClose() event. I also try to use the property opened
but changing it did not show any difference.
My component
{{#power-select-multiple
renderInPlace=true
search=(action "mySearch")
selected=selected_item
onchange=(action (mut selected_item))
oninput=(action "checkPastingMultipleElements")
opened=checkSelect
as |name|
}}
{{name}}
{{/power-select-multiple}}
my action
checkPastingMultipleElements(text, select) {
this.set('selecteded_item', [text]);
// error
// select.actions.close()
// does nothing
// if (text.length === 4) { this.set('checkSelect', false); }
return false; // if true, it executes the search
}
Your initial guess was right, using select.actions.close
is possible, but you have to enqueue this in the runloop to avoid a double-render problem.
Also, if what you want to do is to select a value and close the select, select.actions.choose
is exactly what you want.
checkPastingMultipleElements(text, select) {
Ember.run.scheduleOnce('actions', null, select.actions.choose, [text]);
}