From f521697b0b54114333229d44c106171e19cf8198 Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Wed, 8 Nov 2023 22:07:05 +0500 Subject: [PATCH 1/2] fix: add null check to emoji suggestions --- .../report/ReportActionCompose/Suggestions.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/Suggestions.js b/src/pages/home/report/ReportActionCompose/Suggestions.js index 0050b56800cc..6e3837682051 100644 --- a/src/pages/home/report/ReportActionCompose/Suggestions.js +++ b/src/pages/home/report/ReportActionCompose/Suggestions.js @@ -46,7 +46,24 @@ 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 From ebff8c88d77677e06bbd241356e88e17d5d81f5c Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Wed, 8 Nov 2023 22:47:26 +0500 Subject: [PATCH 2/2] fix: lint issues --- src/pages/home/report/ReportActionCompose/Suggestions.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/Suggestions.js b/src/pages/home/report/ReportActionCompose/Suggestions.js index 6e3837682051..05f35713c5f8 100644 --- a/src/pages/home/report/ReportActionCompose/Suggestions.js +++ b/src/pages/home/report/ReportActionCompose/Suggestions.js @@ -62,7 +62,6 @@ function Suggestions({ } return []; - }, []); /**