Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tab & esc conditions #71

Open
gurgeous opened this issue Dec 3, 2018 · 0 comments
Open

tab & esc conditions #71

gurgeous opened this issue Dec 3, 2018 · 0 comments

Comments

@gurgeous
Copy link

gurgeous commented Dec 3, 2018

Users of autocomplete systems have come to expect the following:

  1. Hitting ESC should close the autocomplete.
  2. Hitting TAB should select the first item if nothing is active. Hitting TAB if an item is active should do nothing.

It's easy to add this behavior outside the library, but the AlphaNum Conditions are too aggressive. We should add these Conditions to prevent re-renders for those keys. Here's my code to workaround the issue:

    // autocomplete-js is very aggressive about handling keys. Even keys like
    // TAB and ESC cause a re-render, which conflicts with our handling of those
    // keys. Let's reach in there and turn off those keys.
    const conditions = this.autocomplete.KeyboardMappings.AlphaNum.Conditions;
    conditions.push({ Is: 9, Not: true });
    conditions.push({ Is: 27, Not: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant