Skip to content

Commit

Permalink
Merge pull request #31072 from allroundexperts/fix-31027
Browse files Browse the repository at this point in the history
fix: add null check to emoji suggestions
  • Loading branch information
pecanoro authored Nov 8, 2023
2 parents 0cb9969 + ebff8c8 commit 05586ea
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/pages/home/report/ReportActionCompose/Suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,23 @@ function Suggestions({
const suggestionEmojiRef = useRef(null);
const suggestionMentionRef = useRef(null);

const getSuggestions = useCallback(() => suggestionEmojiRef.current.getSuggestions() || suggestionMentionRef.current.getSuggestions(), []);
const getSuggestions = useCallback(() => {
if (suggestionEmojiRef.current && suggestionEmojiRef.current.getSuggestions) {
const emojiSuggestions = suggestionEmojiRef.current.getSuggestions();
if (emojiSuggestions.length > 0) {
return emojiSuggestions;
}
}

if (suggestionMentionRef.current && suggestionMentionRef.current.getSuggestions) {
const mentionSuggestions = suggestionMentionRef.current.getSuggestions();
if (mentionSuggestions.length > 0) {
return mentionSuggestions;
}
}

return [];
}, []);

/**
* Clean data related to EmojiSuggestions
Expand Down

0 comments on commit 05586ea

Please sign in to comment.