Meteor-Community-Packages / meteor-autocomplete

Client/server autocompletion designed for Meteor's collections and reactivity.
https://atmospherejs.com/mizzao/autocomplete
MIT License
350 stars 109 forks source link

In single field autocompletion, you can't go to the next input with the 'TAB' key #64

Closed lowi closed 9 years ago

lowi commented 9 years ago

While using the autocomplete package with a single field autocompletion, the TAB key selects the current selection, but it does not switch the focus to the next input (also SHIFT+TAB does not work).

When there is no match for the selection, we can't switch to the next input with TAB.

I think the TAB key should not interfere with the regular focus. After testing on the demo page, after hitting RETURN key (in single field autocompletion), the input loses the focus (I think it should not).

mizzao commented 9 years ago

Hi @lowi, a couple of comments:

The TAB key is used to select one of the current menu items in the autocomplete, so it is overridden. In general we would not want to jump to the next input when pressing it with autocompleted tokens. It's possible that we can do this just for single field mode. Would that do what you want?

The RETURN key currently gives up focus in autocomplete mode, because otherwise the autocomplete menu stays open. What would you like to happen in this case?

lowi commented 9 years ago

Hi @mizzao,

Yes, I think in single field mode, it should select the highlighted entry and move to the next input. I guess the code should let the event continue as normal (so probably not call e.preventDefault() ?)

As for the RETURN key, would it be possible to grab the focus again on the text input after 1ms? That way the autocomplete menu is closed, and the focus is not lost.

mizzao commented 9 years ago

Hi @lowi,

I've revamped this behavior in 0.4.9. Tab and enter both work as normal after a selection has occurred, but it requires a second press to actually do so (otherwise, it seemed to violate the principle of least surprise as one key press would do both actions simultaneously).

Maybe you should play with it just to see if it is more natural: http://autocomplete.meteor.com/. One limitation is that the menu slightly delays in closing; this is something that I haven't figured out how to work around yet as it depends on the keyDown and keyUp events.