vue-multiselect icon indicating copy to clipboard operation
vue-multiselect copied to clipboard

Explicitly check type of search

Open mylesboone opened this issue 3 years ago • 7 comments

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()
      }

mylesboone avatar Oct 22 '21 04:10 mylesboone

Thanks - can we get this fix for #1421 merged?

A more compact fix could simply just be: this.$refs.search?.blur()

BARNZ avatar Nov 02 '21 05:11 BARNZ

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 avatar Nov 15 '21 11:11 chonsser

@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.

mylesboone avatar Apr 27 '22 19:04 mylesboone

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 avatar Apr 28 '22 12:04 Namstel

@Namstel can you check now? I've removed the optional chaining.

mylesboone avatar Apr 28 '22 14:04 mylesboone

Hey @mylesboone It seems to be working now. 👍 I've added a suggestion as well. See above.

Namstel avatar May 05 '22 11:05 Namstel

@Namstel I added in your suggestion. @shentao are you on board with this?

mylesboone avatar May 26 '22 13:05 mylesboone