does not work with react-native-confirmation-code-field library
Feature request
Hello everyone, soft input does not want to work with the react-native-confirmation-code-field library, how can I make it work?
<CodeField ref={ref} {...confirmationCodeProps} value={code} onChangeText={onChangeCode} cellCount={data.CODE_VERIFICATION_LENGTH} keyboardType="number-pad" textContentType="oneTimeCode" renderCell={renderCell} />
hey @adamshels1, could you provide an example repo where you use that library?
@mateusz1913 `import React, { FC, useCallback } from 'react'; import { AvoidSoftInput } from 'react-native-avoid-softinput'; import { CodeField, Cursor, useBlurOnFulfill, useClearByFocusCell } from 'react-native-confirmation-code-field'; import { data } from '@constants/index'; import { useKeyboard } from '@react-native-community/hooks'; import { useFocusEffect } from '@react-navigation/native';
const { keyboardHeight } = useKeyboard();
const onFocusEffect = React.useCallback(() => {
AvoidSoftInput.setShouldMimicIOSBehavior(true);
AvoidSoftInput.setEnabled(true);
AvoidSoftInput.setAvoidOffset(keyboardHeight - 100);
return () => {
AvoidSoftInput.setAvoidOffset(0);
AvoidSoftInput.setEnabled(false);
AvoidSoftInput.setShouldMimicIOSBehavior(false);
};
}, [keyboardHeight]);
useFocusEffect(onFocusEffect);
const renderContent = useCallback(() => {
return (
<Flex paddingHorizontal={32}>
<CodeField
ref={ref}
{...confirmationCodeProps}
value={code}
onChangeText={onChangeCode}
cellCount={data.CODE_VERIFICATION_LENGTH}
keyboardType="number-pad"
textContentType="oneTimeCode"
renderCell={renderCell}
/>
<Button
text="Confirm"
backgroundColor={StyleGuide.palette.blue}
onPress={onCompleteTransfer}
disabled={code?.length !== data.CODE_VERIFICATION_LENGTH}
/>
<Spacer height={10} />
<Button
text="Cancel"
variant="tinted"
borderColor={StyleGuide.palette.grey}
textColor={StyleGuide.palette.grey}
onPress={onCancel}
/>
<BottomSafeArea />
</Flex>
);
}, [
code,
confirmTransferViaSMS,
confirmationCodeProps,
isAuthenticator,
loading,
onCancel,
onChangeCode,
onChangeConfirmationSettings,
onCompleteTransfer,
onGenerateOTP,
onResendCode,
ref,
renderCell,
renderText,
]);
return <BottomSheetModalCustom forwardRef={forwardRef} renderContent={renderContent} isScrollView={false} />;
}; `
this is not the whole code, it's just for example
@adamshels1 could you provide an example repo (the link so I can clone it) and not some arbitrary snippet of code?
Surprise Surprise...
react-native-confirmation-code-field is my library)
I tried to reproduce an issue in a demo project: (https://github.com/retyui/react-native-avoid-softinput-issues-183/blob/main/Test.tsx)
@adamshels1 can you confirm that it works the same for you
| iOS | Android |
|
https://github.com/mateusz1913/react-native-avoid-softinput/assets/4661784/b9cc27aa-b46f-455b-87c3-03abc3a661b1 |
https://github.com/mateusz1913/react-native-avoid-softinput/assets/4661784/50824135-c429-4631-87a7-111f4a0d8832 |