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
(cherry picked from commit 05586ea)
  • Loading branch information
pecanoro authored and OSBotify committed Nov 8, 2023
1 parent 0bfb9c9 commit f93b0dd
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 f93b0dd

Please sign in to comment.