Skip to content

Commit

Permalink
fix(#1806): ApplicationNotResponding: ANR for at least 5000 ms (#1807)
Browse files Browse the repository at this point in the history
Co-authored-by: iGroza <[email protected]>
  • Loading branch information
iGroza and iGroza authored Mar 19, 2024
1 parent 756fd6f commit b2cc44d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/ui/text-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {
useCallback,
useEffect,
useLayoutEffect,
useMemo,
useRef,
useState,
} from 'react';
Expand Down Expand Up @@ -33,7 +34,7 @@ import {Text, TextProps} from '@app/components/ui/text';
import {createTheme} from '@app/helpers';
import {I18N} from '@app/i18n';
import {sleep} from '@app/utils';
import {IS_IOS} from '@app/variables/common';
import {IS_ANDROID, IS_IOS} from '@app/variables/common';

type Props = Omit<TextInputProps, 'placeholder'> & {
label: I18N;
Expand Down Expand Up @@ -128,7 +129,7 @@ export const TextField: React.FC<Props> = memo(
}, [value, focusAnim, isFocused]);

useLayoutEffect(() => {
if (!autoFocus) {
if (!autoFocus || IS_ANDROID) {
return;
}

Expand All @@ -148,6 +149,13 @@ export const TextField: React.FC<Props> = memo(
};
}, [autoFocus]);

const enableAutoFocus = useMemo(() => {
if (IS_ANDROID) {
return autoFocus;
}
return false;
}, [autoFocus]);

let color = getColor(error ? Color.textRed1 : Color.textBase2);

const labelAnimStyle = useAnimatedStyle(
Expand Down Expand Up @@ -204,6 +212,7 @@ export const TextField: React.FC<Props> = memo(
onBlur={onBlurEvent}
onFocus={onFocusEvent}
numberOfLines={numberOfLines}
autoFocus={enableAutoFocus}
/>
</View>
{rightAction && <View style={styles.sub}>{rightAction}</View>}
Expand Down

0 comments on commit b2cc44d

Please sign in to comment.