brianvoe / slim-select

Slim advanced select dropdown
http://slimselectjs.com
MIT License
1.05k stars 200 forks source link

Slimselect does not open when receives Tab from anythere. #454

Closed arriterx closed 1 year ago

arriterx commented 1 year ago

Describe the bug I have input with tabindex = 3 and slimselect with tabindex = 4 When I press TAB I expect that slimselect would automatically Open, but this does not happen.

To archive this I wrote a little patch, which adds the focus event binded to mainDiv (and fixes click+focus issue instantly araised). If it's possible to apply this to next release, maybe someone like me might find it useful.

let slimSelect = new SlimSelect({ select: "#select" }),
    render = slimSelect.render,
    toggle = t => t ? render.callbacks.close() : render.callbacks.open()
render.main.main.onclick = () => {
    if (render.settings.disabled || render.lock) return;
    toggle(render.settings.isOpen)
};
render.main.main.onfocus = () => {
    if (render.settings.disabled || render.lock) return;
    toggle(render.settings.isOpen)
    render.lock = true
    setTimeout(() => render.lock = false, 200)
}

Best regards and thank you for your attention.

brianvoe commented 1 year ago

It did used to do that. Looks like other prs altered that. I do think that should be put back in. If you submit a pr ill get it merged in.

Shoplifter commented 1 year ago

I am really not stubborn about this and can live with either way. Anyhow - the behaviour I would expect is that of a regular select field, i.e. focus just sets styles and - if focused - select opens on pressing the space key. So maybe as an optional feature?

brianvoe commented 1 year ago

I just ran a codepen with a few input fields in it and a select and @Shoplifter is correct it doesn't automatically open. I think we should keep it mimicing the same default behavior as a normal select in this instance.

If someone wants to add an optional auto open on tab I would be ok with that as well.