jm-david / emoji-mart-vue

One component to pick them all 👊🏼
https://jm-david.github.io/emoji-mart-vue
BSD 3-Clause "New" or "Revised" License
603 stars 82 forks source link

Fix previousInclude and previousExclude checks. #4

Closed ellisio closed 7 years ago

ellisio commented 7 years ago

The current implementation requires you to always define :include AND :exclude for search to work. For example, if you do the following:

<picker
    set="apple"
    :emoji-size="16"
    :per-line="12"
    :exclude="['custom']"
    @click="addEmoji">
</picker>

Then attempt to search, you will receive the following JS error:

vendor.js:11692 Uncaught TypeError: Cannot read property 'sort' of undefined
    at Object.search (vendor.js:11692)
    at VueComponent.onInput (vendor.js:11532)
    at boundFn (vendor.js:93445)
    at HTMLInputElement.invoker (vendor.js:95018)

By doing the following, the error goes away:

<picker
    set="apple"
    :emoji-size="16"
    :per-line="12"
    :include="[]"
    :exclude="['custom']"
    @click="addEmoji">
</picker>

There is no reason to require the developer to have the empty :include just to get searching working. So this fix will break the checks apart for previousInclude and previousExclude to resolve this issue.

jm-david commented 7 years ago

Looks great, thank you :)