Open drewcovi opened 6 years ago
Yes, it is. But I took select2 as role model for this. Buy you can change it if you want
@cibernox how can i change it? you mean just fork it? or is this configurable?
Ember Power Select is pretty customizable. By example, you can achieve the behaviour you want using only public API.
If you want to customize what the component does when the user presses a key, you can pass onkeydown=(action "yourCustomAction")
and do whatever you want.
In this example:
{{#power-select-multiple options=options selected=selected onchange=(action (mut selected)) onkeydown=(action "handleKeydown") as |opt|}}
{{opt}}
{{/power-select-multiple}}
actions: {
handleKeydown(select, e) {
if (e.keyCode === 8 && Ember.isBlank(e.target.value)) { // press backspace on empty searchbox
select.actions.select(select.selected.slice(0, select.selected.length - 1), e); // remove last selection
return false; // prevent usual default behavior
}
}
}
You can see a twiddle here: https://ember-twiddle.com/42c561f23fc4184e143048813dda3ae7?openFiles=controllers.application.js%2C
Is it by design that backspace on a multiple-select converts pills into text? Many other libraries adopt a pattern of removing the entire pill.