Skip to content

Commit

Permalink
fix(HW-994): incorrect keyboard behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
iGroza committed Dec 9, 2024
1 parent 04efb2c commit d15f398
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions src/components/ui/text-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import React, {
memo,
useCallback,
useEffect,
useLayoutEffect,
useMemo,
useRef,
useState,
} from 'react';

import {
I18nManager,
InteractionManager,
Keyboard,
LayoutChangeEvent,
NativeSyntheticEvent,
Pressable,
Expand All @@ -37,8 +34,7 @@ import {Spacer} from '@app/components/ui/spacer';
import {Text, TextProps, TextVariant} from '@app/components/ui/text';
import {createTheme, showModal} from '@app/helpers';
import {I18N, getText} from '@app/i18n';
import {sleep} from '@app/utils';
import {IS_ANDROID, IS_IOS} from '@app/variables/common';
import {IS_IOS} from '@app/variables/common';

import {Button, ButtonSize} from './button';
import {First} from './first';
Expand Down Expand Up @@ -145,32 +141,8 @@ export const TextField: React.FC<TextFieldProps> = memo(
});
}, [value, focusAnim, isFocused]);

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

const interaction = InteractionManager.runAfterInteractions(async () => {
if (!inputRef.current?.isFocused()) {
Keyboard.dismiss();
await sleep(100);
inputRef.current?.focus();
}
});

return () => {
interaction.cancel();
if (inputRef.current?.isFocused()) {
inputRef.current?.blur();
}
};
}, [autoFocus]);

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

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

0 comments on commit d15f398

Please sign in to comment.