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

Autocomplete keyArrows attempts to select past end of list #2707

Closed
cybercode opened this issue Jul 24, 2020 · 0 comments · Fixed by #2714
Closed

Autocomplete keyArrows attempts to select past end of list #2707

cybercode opened this issue Jul 24, 2020 · 0 comments · Fixed by #2714

Comments

@cybercode
Copy link
Contributor

Overview of the problem

Buefy version: 0.8.20
Vuejs version: 2.6.11
OS/Browser: macOS, chrome, firefox, safari

Description

When the down arrow is pressed on the last element in the dropdown, the control attempts to setHovered on an item one past the end of the list (it sets index wrong):

        keyArrows(direction) {
            const sum = direction === 'down' ? 1 : -1
            if (this.isActive) {
                let index = this.data.indexOf(this.hovered) + sum
                index = index > this.data.length - 1 ? this.data.length : index
                index = index < 0 ? 0 : index

                this.setHovered(this.data[index])

should be:

        keyArrows(direction) {
            const sum = direction === 'down' ? 1 : -1
            if (this.isActive) {
                let index = this.data.indexOf(this.hovered) + sum
                index = index > this.data.length - 1 ? this.data.length - 1 : index
                index = index < 0 ? 0 : index

                this.setHovered(this.data[index])
jtommy pushed a commit that referenced this issue Jul 27, 2020
* Correctly set the index for hover on arrow key

* Remove .prettierrc

Co-authored-by: Ross Coundon <ross.coundon@leadent.digital>
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

Successfully merging a pull request may close this issue.

1 participant