react-native-modalbox icon indicating copy to clipboard operation
react-native-modalbox copied to clipboard

the keyboard will cover the modal

Open jinghun1999 opened this issue 9 years ago • 5 comments

when i put a TextInput in the modal, when textinput focus,the keyboard show, and it will cover the modal, i can't see the modal any more, how can i fix it?

jinghun1999 avatar Sep 12 '16 12:09 jinghun1999

I do not even see the keyboard, nothing happens. Also, the TextInput shows no value, whatever I may use as 'value' there.

af-inf avatar Sep 16 '16 16:09 af-inf

Same for me, I tried to use 'KeyboardAvoidingView' but all the view goes up, it would be nice that only the modal moves up but I'm not able to do it with 'KeyboardAvoidingView'. The best way would be to animate it manually modifying the bottom position.

DonovanCharpin avatar Sep 23 '16 17:09 DonovanCharpin

I found a way to do it! The keyboard goes up on my side with this code.

<KeyboardAvoidingView style={FiltersStyles.container} contentContainerStyle={FiltersStyles.container} behavior={'position'}>
  <Modal isOpen={this.props.open} style={styles.modalContainer} backdrop={false} position={"bottom"}
         entry={"bottom"}>
    <Text>Test modal with keyboard</Text>
  </Modal>
</KeyboardAvoidingView>

and the style

const styles = StyleSheet.create({
  container: {
    position: 'absolute',
    bottom: 0,
    left: 0,
    flex: 1,
    width: Dimensions.get('window').width,
    height: Dimensions.get('window').height,
  },
  modalContainer: {
    height: Dimensions.get('window').height * .3,
    width: Dimensions.get('window').width,
    backgroundColor: 'red'
  }
});

DonovanCharpin avatar Sep 23 '16 18:09 DonovanCharpin

fond one way as a workaround:

constructor(props) {
        super(props);
        this.state = {
            keyboardSpace:0
            nicknameModalVisible:true,
        };
        
        //for get keyboard height
        Keyboard.addListener('keyboardDidShow',(frames)=>{
            if (!frames.endCoordinates) return;
            this.setState({keyboardSpace: frames.endCoordinates.height});
        });
        Keyboard.addListener('keyboardDidHide',(frames)=>{
            this.setState({keyboardSpace:0});
        });
}
<Modal
  isOpen={this.state.modalVisible}
  style={{
         position: 'absolute',
         bottom: 0,
         //change modal position by keyboardspace
         top:this.state.keyboardSpace?-10-this.state.keyboardSpace: -250,
         padding:20,
         width:250,
         height:150,
         borderRadius:15
        }}
        position={"bottom"}
        ref={"modal"}
        onClosed={()=> {
            this.setState({modalVisible:false});
  		}}
          >
            //your content
</Modal>

tim 20170811143341 tim 20170811143401

c446984928 avatar Aug 11 '17 06:08 c446984928

Got it working @c446984928 thanks for the keyboard listener work around

image 2018-09-07 16 03 52 image 2018-09-07 16 03 54

reyn-nova avatar Sep 07 '18 09:09 reyn-nova