vue-multiselect
vue-multiselect copied to clipboard
Explicitly check type of search
This is an attempt to fix https://github.com/shentao/vue-multiselect/issues/1421
It seems that current ln 677 of multiselectMixin.js
if (this.searchable) {
this.$refs.search && this.$refs.search.blur()
} else {
this.$el.blur()
}
ends up compiling to
this.searchable?this.$refs.search.blur():this.$el.blur()
Changing this to
if (this.searchable) {
this.$refs.search?.blur()
} else {
this.$el.blur()
}
Thanks - can we get this fix for #1421 merged?
A more compact fix could simply just be: this.$refs.search?.blur()
We should also add the check before this.$el.blur()
. The this.$el
might got undefined at specific conditions.
@mylesboone Can you apply the fix for that here as well?
@chonsser done. I changed to just use the safe operator and also did the same in the else
. It sounds like @shentao is looking to merge this in and put it in a release.
It looks good, but the optional chaining doesn't seem to be working with the current setup of the project. I'm getting the following error when I do npm run dev
:
Add @babel/plugin-proposal-optional-chaining (https://git.io/vb4Sk) to the 'plugins' section of your Babel config to enable transformation.
Adding the plugin also doesn't seem to work, because when I try to bundle it, I get:
Module build failed: SyntaxError: /home/niels/Desktop/git/vue-multiselect/src/multiselectMixin.js: Support for the experimental syntax 'optionalChaining' isn't currently enabled (660:47):
@Namstel can you check now? I've removed the optional chaining.
Hey @mylesboone It seems to be working now. 👍 I've added a suggestion as well. See above.
@Namstel I added in your suggestion. @shentao are you on board with this?