Skip to content

Commit

Permalink
Merge pull request #25660 from WikusKriek/25649-Mention-list-doesnt-a…
Browse files Browse the repository at this point in the history
…utomatically-popup-when-typing

Mention list doesnt automatically popup when typing @
  • Loading branch information
Beamanator authored Aug 24, 2023
2 parents 0196aa2 + d4e4d85 commit 9a6c643
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,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 @@ -642,24 +642,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 @@ -991,6 +980,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

0 comments on commit 9a6c643

Please sign in to comment.