Skip to content

Commit ffb5d1e

Browse files
committed
Fix - After adding the emoji, the cursor starts overlapping with the message text
1 parent adab045 commit ffb5d1e

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/components/Modal/ReanimatedModal/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,13 @@ function ReanimatedModal({
138138
if (handleRef.current) {
139139
InteractionManager.clearInteractionHandle(handleRef.current);
140140
}
141-
}, []);
141+
// Because on Android, the Modal's onDismiss callback does not work reliably. There's a reported issue at:
142+
// https://stackoverflow.com/questions/58937956/react-native-modal-ondismiss-not-invoked
143+
// Therefore, we manually call onModalHide() here for Android.
144+
if (getPlatform() === CONST.PLATFORM.ANDROID) {
145+
onModalHide();
146+
}
147+
}, [onModalHide]);
142148

143149
const containerView = (
144150
<Container
@@ -197,7 +203,9 @@ function ReanimatedModal({
197203
testID={testID}
198204
onDismiss={() => {
199205
onDismiss?.();
200-
onModalHide();
206+
if (getPlatform() !== CONST.PLATFORM.ANDROID) {
207+
onModalHide();
208+
}
201209
}}
202210
// eslint-disable-next-line react/jsx-props-no-spreading
203211
{...props}

src/pages/settings/Profile/CustomStatus/StatusPage.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ import usePermissions from '@hooks/usePermissions';
2222
import useStyleUtils from '@hooks/useStyleUtils';
2323
import useTheme from '@hooks/useTheme';
2424
import useThemeStyles from '@hooks/useThemeStyles';
25+
import {isMobileChrome} from '@libs/Browser';
2526
import DateUtils from '@libs/DateUtils';
2627
import focusAfterModalClose from '@libs/focusAfterModalClose';
28+
import focusComposerWithDelay from '@libs/focusComposerWithDelay';
2729
import {formatPhoneNumber} from '@libs/LocalePhoneNumber';
2830
import Navigation from '@libs/Navigation/Navigation';
2931
import {getPersonalDetailByEmail} from '@libs/PersonalDetailsUtils';
@@ -213,7 +215,15 @@ function StatusPage() {
213215
role={CONST.ROLE.PRESENTATION}
214216
defaultValue={defaultEmoji}
215217
style={styles.mb3}
216-
onModalHide={() => focusAfterModalClose(inputRef.current)}
218+
onModalHide={() => {
219+
// On mobile Chrome, the input will blur immediately upon focus if the focus function is called right after the modal closes, even though the modal has fully closed.
220+
// Therefore, use the `focusComposerWithDelay` helper as used in `ComposerWithSuggestions` for this case.
221+
if (isMobileChrome()) {
222+
focusComposerWithDelay(inputRef.current)(true);
223+
} else {
224+
focusAfterModalClose(inputRef.current);
225+
}
226+
}}
217227
// eslint-disable-next-line @typescript-eslint/no-unused-vars
218228
onInputChange={(emoji: string): void => {}}
219229
/>

0 commit comments

Comments
 (0)