Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention list doesnt automatically popup when typing @ #25660

Merged
Changes from 4 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 = (e) => {
LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity));
setSelection(e.nativeEvent.selection);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useCallback can still be used with empty dependency array

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump for this minor change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @situchan.


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
Loading