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 to complete as a prop #208

Open
usernamehw opened this issue Nov 11, 2020 · 2 comments
Open

Tab to complete as a prop #208

usernamehw opened this issue Nov 11, 2020 · 2 comments

Comments

@usernamehw
Copy link

usernamehw commented Nov 11, 2020

Problem description:

It was already filed before: #94, #172. But what was proposed is more of a hack. It's not good enough, because it also prevents tabbing out of the input. The tab handler should only prevent default behavior when autocomplete is visible, not at all times.

It is possible to "hackaround" it harder:

<vue-autosuggest @keydown.tab="tabHandler" />
tabHandler(e: KeyboardEvent) {
    const { listeners, setCurrentIndex, setChangeItem, getItemByIndex } = this.$refs.autosuggest;
    const item = getItemByIndex(this.$refs.autosuggest.currentIndex);
    if (!item) {
        return;
    }
    e.preventDefault();
    setChangeItem(item, true);
    this.$refs.autosuggest.loading = true;
    listeners.selected(true);
}

But a simple api prop would be the best solution.

Suggested solution:

Create a boolean prop accept-on-tab that would work only when autocomplete suggestions are visible.

It's a common enough feature that I've seen in multiple typeahead libraries.

@darrenjennings
Copy link
Owner

@usernamehw I like it. Would you open to submitting a PR?

@usernamehw
Copy link
Author

usernamehw commented Nov 21, 2020

I think such things are better left to repository owner. It would take a lot more time for me to build it and make this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants