Skip to content

Commit

Permalink
fix: broken search when using [emojisToShowFilter] #182 (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-moran authored and scttcper committed Dec 8, 2019
1 parent 8059960 commit fec43c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@ export class AppComponent {
handleClick($event: EmojiEvent) {
console.log($event.emoji);
}
emojiFilter(e: string): boolean {
// Can use this to test [emojisToShowFilter]
if (e && e.indexOf && e.indexOf('1F4') >= 0) {
return true;
}
return false;
}
}
9 changes: 6 additions & 3 deletions src/lib/picker/emoji-search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@ export class EmojiSearch {

if (results) {
if (emojisToShowFilter) {
results = results.filter((result: EmojiData) =>
emojisToShowFilter(this.emojiService.names[result.id]),
);
results = results.filter((result: EmojiData) => {
if (result && result.id) {
return emojisToShowFilter(this.emojiService.names[result.id].unified);
}
return false;
});
}

if (results && results.length > maxResults) {
Expand Down

0 comments on commit fec43c6

Please sign in to comment.