react-native-confirmation-code-field icon indicating copy to clipboard operation
react-native-confirmation-code-field copied to clipboard

Don't see numbers inputted

Open Viktor-as opened this issue 1 year ago • 0 comments

Hey,

basically I was having the same problem as in this issue.

On most of the phones that I tested everything was ok, but on some (like Huawei pro 20 (Android 10)) the numbers that you input were not shown.

Accidently discovered that if you specify the colors for cursor (like here) and for input - then everything is ok, and I started seeing my input also on Huawei Pro 20.

Maybe this could be fixed or added to the documentation. Hope this helps.

                       <CodeField
                          ref={ref}
                          {...props}
                          value={value}
                          onChangeText={val => {
                            setFieldValue('code', val);
                            setValue(val);
                          }}
                          cellCount={CELL_COUNT}
                          rootStyle={styles.codeFieldRoot}
                          keyboardType="number-pad"
                          textContentType="oneTimeCode"
                          renderCell={({index, symbol, isFocused}) => (
                            <Text
                              key={index}
                              style={[
                                styles.cell,
                                isFocused && styles.focusCell,
                              ]}
                              onLayout={getCellOnLayoutHandler(index)}>
                              {symbol ||
                                (isFocused ? (
                                  <Text style={{color: '#000'}}> // ← this line -------------------------
                                    <Cursor />
                                  </Text>
                                ) : null)}
                            </Text>
                          )}
                        />
const styles = StyleSheet.create({
  root: {flex: 1, paddingLeft: vwNumber(60), paddingRight: vwNumber(60)},
  codeFieldRoot: {marginTop: 30, paddingBottom: 30},
  cell: {
    width: 30,
    height: 30,
    lineHeight: 20,
    fontSize: 17,
    borderWidth: 1,
    backgroundColor: 'white',
    borderColor: '#000',
    textAlign: 'center',
    color: '#000', // ← this line ----------------------
    paddingTop: 5,
  },
  focusCell: {
    borderColor: '#000',
  },
});

Viktor-as avatar Jan 29 '24 08:01 Viktor-as