8.3 C
London
Wednesday, December 13, 2023

javascript – Keyboard dismissed on drag ScrollView content material iOS solely


In React Native app I’m utilizing react-native-modal and inside the modal there’s a KeyboardAvoidingView that comprises ScrollView. Once I press any textInput keyboard exhibits up, if I drag ScrollView content material (to scroll down) by urgent any TextInput it really works simply tremendous and keyboard doesn’t dissmiss, however after I begin draging it by urgent the area between inputs it dissmisses keyboard on launch.

Code beneath:

  return (
  <Modal
      testID={'modal'}
      isVisible={modalVisible}
      propagateSwipe={true}
      onBackButtonPress={handleModalClose}
      onBackdropPress={handleModalClose}
      backdropColor={colours.transparentBlack}
      fashion={types.modal}>
    <View fashion={types.container}>
      <CustomText fashion={types.title}>{'Edit'}</CustomText>
      <Formik
        initialValues={initialValues}
        onSubmit={handleSubmisson}
        validationSchema={validationSchema}>
        {({handleSubmit}) => (
          <KeyboardAvoidingView
            fashion={types.avoidViewContainer}
            conduct={Platform.OS === 'ios' ? 'padding' : undefined}
            keyboardVerticalOffset={50}>
            <ScrollView
              fashion={types.inputsContainer}
              keyboardShouldPersistTaps="dealt with"
              contentContainerStyle={{justifyContent: 'middle', flexGrow: 1}}>
              <ErrorsListComponent />
              <TextInput
                fashion={{width: '50%, top: 50, backgroundColor: 'blue'}}
                keyboardType={
                  Platform.OS === 'android' ? 'numeric' : 'number-pad'
                }
              />
            </ScrollView>
            <Button
              title="Save"
              additionalButtonStyle={types.button}
              additionalTextStyle={{coloration: colours.white}}
              onPress={handleSubmit}
            />
          </KeyboardAvoidingView>
        )}
      </Formik>
    </View>
  </Modal>
  );
};

const types = StyleSheet.create({
  modal: {
    justifyContent: 'flex-end',
    margin: spacing._0,
  },
  container: {
    alignItems: 'middle',
    flex: 1,
  },
  inputsContainer: {
    width: '80%',
    top: '80%',
  },
  title: {
    fontSize: fontSize._20,
    coloration: colours.black,
    fontWeight: '700',
    marginVertical: spacing._10,
  },
  button: {
    backgroundColor: colours.secondary,
    width: '50%',
    top: 50,
    borderWidth: 0,
    alignSelf: 'middle',
    justifyContent: 'middle',
    marginVertical: spacing._5,
  },
  avoidViewContainer: {
    alignItems: 'middle',
    flex: 1,
    width: '100%',
  },

Does anybody know what’s the cause keyboard dismisses on drag in case of beginning dragging out of enter area? It occurs just for iOS.

I’ve tried altering types, approach parts comprises one another, however with similar end result…

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here