From 375d0d24e20b2e6c97ce5e58a38551872b068400 Mon Sep 17 00:00:00 2001 From: Eric Han Date: Tue, 14 Nov 2023 11:26:31 +0800 Subject: [PATCH 1/2] Fix: emoji suggestion does't reopen on revisit --- .../home/report/ReportActionCompose/SuggestionEmoji.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionEmoji.js b/src/pages/home/report/ReportActionCompose/SuggestionEmoji.js index dc84f77b6311..765ccecaeefc 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionEmoji.js +++ b/src/pages/home/report/ReportActionCompose/SuggestionEmoji.js @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import React, {useCallback, useImperativeHandle, useRef, useState} from 'react'; +import React, {useCallback, useEffect, useImperativeHandle, useRef, useState} from 'react'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import EmojiSuggestions from '@components/EmojiSuggestions'; @@ -59,6 +59,7 @@ function SuggestionEmoji({ forwardedRef, resetKeyboardInput, measureParentContainer, + isComposerFocused, }) { const [suggestionValues, setSuggestionValues] = useState(defaultSuggestionsValues); @@ -180,6 +181,12 @@ function SuggestionEmoji({ [value, preferredLocale, setHighlightedEmojiIndex, resetSuggestions], ); + useEffect(() => { + if (isComposerFocused) { + calculateEmojiSuggestion(selection.end); + } + }, [selection, calculateEmojiSuggestion, isComposerFocused]); + const onSelectionChange = useCallback( (e) => { /** From 0845f628571080af6a81f687a4e7094c9f718b55 Mon Sep 17 00:00:00 2001 From: Eric Han Date: Tue, 14 Nov 2023 11:46:49 +0800 Subject: [PATCH 2/2] fix lint --- src/pages/home/report/ReportActionCompose/SuggestionEmoji.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionEmoji.js b/src/pages/home/report/ReportActionCompose/SuggestionEmoji.js index 765ccecaeefc..20766a55b507 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionEmoji.js +++ b/src/pages/home/report/ReportActionCompose/SuggestionEmoji.js @@ -182,9 +182,10 @@ function SuggestionEmoji({ ); useEffect(() => { - if (isComposerFocused) { - calculateEmojiSuggestion(selection.end); + if (!isComposerFocused) { + return; } + calculateEmojiSuggestion(selection.end); }, [selection, calculateEmojiSuggestion, isComposerFocused]); const onSelectionChange = useCallback(