ember-power-select
ember-power-select copied to clipboard
Add option to not close select on tab keypress
I would like to add an optional property to the power-select component to allow the dropdown to stay open on a "Tab" keypress. You currently can pass the onkeydown method to the component and do some customization that way. You can then return false in this method to prevent the default closing behavior from occurring. But my use case involves tabbing through / focusing content within the dropdown portion of the select. If I were to return false in onkeydown, the default browser focus behavior would also be prevented. Creating this property allows the power-select's default tab behavior to be avoided, while allowing the browser's default tab behavior to be preserved.
@kstinson14 I'm not sure about this:
If I were to return false in onkeydown, the default browser focus behavior would also be prevented
AFAIK, returning false from onkeydown does not prevent any native browser behavior whatsoever, only the default behavior of the select (unless you call event.preventDefault()).
Can you check that and explain a bit more why returning false doesn't work for your use case?
@cibernox Sorry, I should've included this in the original post: I have an ember-twiddle here that better shows what I mean. If you have an onkeydown handler on an input that returns false, it prevents the focus from changing to the next element in the tab order. You can see this in the second input / button pair in the twiddle.
I also put a small power-select example in there that displays the problem more explicitly. When you click on the trigger to open the component, there are buttons in each of the options. But they can't be tabbed to, because the search input's onkeydown handler returns false. If you alter the power-select component to have searchEnabled=false, the buttons become tab-able, since the input's onkeydown event won't get in the way.
@cibernox Realized I didn't add the attribute to power-select-multiple, should be fixed now.
@kstinson14 I realize this is super old, but could you please rebase and fix conflicts?