Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ function ReportActionCompose({

const calculateMentionSuggestion = useCallback(
(selectionEnd) => {
if (shouldBlockMentionCalc.current || selection.end < 1) {
if (shouldBlockMentionCalc.current || selectionEnd < 1) {
shouldBlockMentionCalc.current = false;
resetSuggestions();
return;
Expand Down Expand Up @@ -631,24 +631,13 @@ function ReportActionCompose({
}));
setHighlightedMentionIndex(0);
},
[getMentionOptions, setHighlightedMentionIndex, value, selection, resetSuggestions],
[getMentionOptions, setHighlightedMentionIndex, value, resetSuggestions],
);

const onSelectionChange = useCallback(
(e) => {
LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity));
setSelection(e.nativeEvent.selection);

/**
* we pass here e.nativeEvent.selection.end directly to calculateEmojiSuggestion
* because in other case calculateEmojiSuggestion will have an old calculation value
* of suggestion instead of current one
*/
calculateEmojiSuggestion(e.nativeEvent.selection.end);
calculateMentionSuggestion(e.nativeEvent.selection.end);
},
[calculateEmojiSuggestion, calculateMentionSuggestion],
);
const onSelectionChange = useCallback((e) => {
LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity));
setSelection(e.nativeEvent.selection);
}, []);

const setUpComposeFocusManager = useCallback(() => {
// This callback is used in the contextMenuActions to manage giving focus back to the compose input.
Expand Down Expand Up @@ -979,6 +968,11 @@ function ReportActionCompose({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
calculateEmojiSuggestion(selection.end);
calculateMentionSuggestion(selection.end);
}, [calculateEmojiSuggestion, calculateMentionSuggestion, selection.end]);

const prevIsModalVisible = usePrevious(modal.isVisible);
const prevIsFocused = usePrevious(isFocusedProp);
useEffect(() => {
Expand Down