Skip to content

Commit

Permalink
Added condition to prevent user mention suggestion from showing when …
Browse files Browse the repository at this point in the history
…composer is not focused
  • Loading branch information
alitoshmatov committed Oct 19, 2023
1 parent 229cb5d commit 5903e5e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ function ComposerWithSuggestions({
<Suggestions
ref={suggestionsRef}
isComposerFullSize={isComposerFullSize}
isComposerFocused={textInputRef.current && textInputRef.current.isFocused()}
updateComment={updateComment}
composerHeight={composerHeight}
measureParentContainer={measureParentContainer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function SuggestionMention({
forwardedRef,
isAutoSuggestionPickerLarge,
measureParentContainer,
isComposerFocused,
}) {
const {translate} = useLocalize();
const [suggestionValues, setSuggestionValues] = useState(defaultSuggestionsValues);
Expand Down Expand Up @@ -181,7 +182,7 @@ function SuggestionMention({

const calculateMentionSuggestion = useCallback(
(selectionEnd) => {
if (shouldBlockCalc.current || selectionEnd < 1) {
if (shouldBlockCalc.current || selectionEnd < 1 || !isComposerFocused) {
shouldBlockCalc.current = false;
resetSuggestions();
return;
Expand Down Expand Up @@ -229,7 +230,7 @@ function SuggestionMention({
}));
setHighlightedMentionIndex(0);
},
[getMentionOptions, personalDetails, resetSuggestions, setHighlightedMentionIndex, value],
[getMentionOptions, personalDetails, resetSuggestions, setHighlightedMentionIndex, value, isComposerFocused],
);

useEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ReportActionCompose/Suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function Suggestions({
resetKeyboardInput,
measureParentContainer,
isAutoSuggestionPickerLarge,
isComposerFocused,
}) {
const suggestionEmojiRef = useRef(null);
const suggestionMentionRef = useRef(null);
Expand Down Expand Up @@ -103,6 +104,7 @@ function Suggestions({
composerHeight,
isAutoSuggestionPickerLarge,
measureParentContainer,
isComposerFocused,
};

return (
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/ReportActionCompose/suggestionProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const baseProps = {

/** Meaures the parent container's position and dimensions. */
measureParentContainer: PropTypes.func.isRequired,

/** Report composer focus state */
isComposerFocused: PropTypes.bool,
};

const implementationBaseProps = {
Expand Down

0 comments on commit 5903e5e

Please sign in to comment.