-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
fix: Chat - App displays mention suggestion for sometime when we remove spaces before #29957
Changes from 5 commits
0ca7dcb
ff4bfdb
a6c8519
f401385
1cb6ba6
95a9dfe
54d1baf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import * as UserUtils from '../../../../libs/UserUtils'; | |
import * as Expensicons from '../../../../components/Icon/Expensicons'; | ||
import * as SuggestionsUtils from '../../../../libs/SuggestionUtils'; | ||
import useLocalize from '../../../../hooks/useLocalize'; | ||
import usePrevious from '../../../../hooks/usePrevious'; | ||
import ONYXKEYS from '../../../../ONYXKEYS'; | ||
import personalDetailsPropType from '../../../personalDetailsPropType'; | ||
import * as SuggestionProps from './suggestionProps'; | ||
|
@@ -56,6 +57,7 @@ function SuggestionMention({ | |
measureParentContainer, | ||
}) { | ||
const {translate} = useLocalize(); | ||
const previousValue = usePrevious(value); | ||
const [suggestionValues, setSuggestionValues] = useState(defaultSuggestionsValues); | ||
|
||
const isMentionSuggestionsMenuVisible = !_.isEmpty(suggestionValues.suggestedMentions) && suggestionValues.shouldShowSuggestionMenu; | ||
|
@@ -233,8 +235,15 @@ function SuggestionMention({ | |
); | ||
|
||
useEffect(() => { | ||
if (value.length < previousValue.length) { | ||
// A workaround to not show the suggestions list when the user deletes a character before the mention. | ||
// It is caused by a buggy behavior of the TextInput on iOS. Should be fixed after migration to the Fabric Arc. | ||
// See: https://github.com/facebook/react-native/pull/36930#issuecomment-1593028467 | ||
return; | ||
} | ||
|
||
calculateMentionSuggestion(selection.end); | ||
}, [selection, calculateMentionSuggestion]); | ||
}, [selection, value, previousValue, calculateMentionSuggestion]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would omit both values from dependencies, but in that case, we get a lint error – it requires both to be present There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, sure. The truth is that we opt-out quite often from that lint... In this case I would go whichever path is less likely to create another regression... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with you @cubuspl42, we should follow the path that is less likely to create another regression. |
||
|
||
const updateShouldShowSuggestionMenuToFalse = useCallback(() => { | ||
setSuggestionValues((prevState) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arc -> Arch (or just "Fabric")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arc:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ark: