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

TypeError: component.data.optionsValues is undefined into selectDown(component) #20

Open
jcroot opened this issue Mar 19, 2021 · 1 comment

Comments

@jcroot
Copy link

jcroot commented Mar 19, 2021

I have an error when I using the down arrow.

Alpine Error: "TypeError: component.data.optionsValues is undefined"

Expression: "selectDown(window.livewire.find('qGYXZk93tJhwpOf1TVQe'))"

Line 23: select.blade.php

selectDown(component) {
if (component.data.optionsValues.length - 1 === this.selectedIndex) {
return
}
this.selectedIndex++
},

@jcroot
Copy link
Author

jcroot commented Mar 19, 2021

I found the error:

component not have "data" attribute, and only need valuate component.optionValues.

In a LivewireSelect component the variable only is optionValues.

selectDown(component) {
            if (component.optionsValues.length - 1 === this.selectedIndex) {
                return
            }
            this.selectedIndex++
        },
        selectIndex(index) {
            this.selectedIndex = index
            this.isOpen = true
        },
        confirmSelection(component) {
            const value = component.optionsValues.length === 1
                ? component.optionsValues[0]
                : component.optionsValues[this.selectedIndex]

            if (!value) {
                return
            }

            component.set('value', value)

            this.selectedIndex = -1
            this.isOpen = true
        },

....

Testing:
"laravel/framework": "^8.12"
"livewire/livewire": "^2.0"

jcroot added a commit to jcroot/livewire-select that referenced this issue Mar 19, 2021
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