shentao / vue-multiselect

Universal select/multiselect/tagging component for Vue.js
https://vue-multiselect.js.org/
MIT License
6.66k stars 991 forks source link

Cannot read properties of null (reading 'blur') when changing view via select on Chrome #1676

Open ztosyl opened 1 year ago

ztosyl commented 1 year ago

Reproduction Link


### Steps to reproduce
- This is 3.0, on Vue 3. See above: have two multiselects that you can toggle between by choosing an option on one of them, an error will throw. This only happens on Chrome. If you trigger the select function that toggles between the selects, the error is thrown.

### Expected behaviour
- This works fine and throws no errors.

### Actual behaviour
An error is thrown implying this.$refs.search is null, and errors on the following line:

if (typeof this.$refs.search !== 'undefined') this.$refs.search.blur();


The error is Cannot read properties of null (reading 'blur').
gllmp commented 1 year ago

Hi, also having the same error when unmouting the VueMultiselect component, it only occurs if the searchable prop is set to true.

The error is thrown by this condition check in multiselectMixin.js, related to PR https://github.com/shentao/vue-multiselect/pull/1497: https://github.com/shentao/vue-multiselect/blob/master/src/multiselectMixin.js#L691

if (this.searchable) {
  if (typeof this.$refs.search !== 'undefined') this.$refs.search.blur()
} else {
  if (typeof this.$el !== 'undefined') this.$el.blur()
}
roelVerdonschot commented 1 year ago

I get the same error

tomassabol commented 1 year ago

same here

10111282 commented 1 year ago

Same error when using dynamic-options-provider. Happens If immediately leave the page while options are still being fetched.

nerminjukan commented 10 months ago

Same error when search input is closed, i.e. searching for a tag and selecting the tag triggers the error.