sagalbot / vue-select

Everything you wish the HTML <select> element could do, wrapped up into a lightweight, extensible Vue component.
https://vue-select.org
MIT License
4.62k stars 1.34k forks source link

Error in getter for watcher "filteredOptions": "TypeError: Cannot read properties of null (reading 'concat')" #1545

Closed lubeHub closed 1 year ago

lubeHub commented 2 years ago

I get error app.js:107129 [Vue warn]: Error in getter for watcher "filteredOptions": "TypeError: Cannot read properties of null (reading 'concat')" whenever I navigate to page with v-select from another page. After that, I reload page (F5) and the error is gone and v-select works normally.

` "

                                       <v-select
                                                option:deselected="deselectedValue()"
                                                :options="podaci"
                                                label="name"
                                                v-model="fields[number]"
                                                :selectable="
                                                    option =>
                                                        !checkIfExist(
                                                            option.name
                                                        )
                                                "
                                                @input="
                                                    setSelectedValue(
                                                        $event,
                                                        number
                                                    )
                                                "
                                            >`

Variable podaci is object.

I am using Opera on Windows 10.

apavelm commented 2 years ago

The same for me

Brownyman commented 2 years ago

I know this is 7 months late, I've just been getting the same issue but I think I've found what was causing it.

Is there a point on first clean load where podaci is null? I notice you dont have a v-if using podaci so it will throw an error when it first loads the component.

I was setting the default value of my options as null and after fetching data for vselect it would load correctly with those errors thrown in console. After setting the default value to [] it was no longer throwing that error.

So as a workaround in place of null value handling within the vselect

ramazansancar commented 1 year ago

The same for me

sagalbot commented 1 year ago

The options prop requires an array - supplying anything else will trigger that error.

apavelm commented 1 year ago

Sometimes (while data is loading) for complex data structures it could be null or undefined. It would be nice if it will be considered as [] inside vue-select. @sagalbot