Skip to content

tab & esc conditions #71

@gurgeous

Description

@gurgeous

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 });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions