我在屏幕底部有一个文本输入,按下时会扩展为更大的部分,并带有一些选项。bottomHeight
并height
在键盘打开时增加。
当按下额外容器中的这些预定义tags
之一时,我不想关闭键盘,但我无法使其工作并且可以使用一些帮助。
我已经将它包装textinput
在一个滚动视图中以尝试使用keyboardShouldPersistTaps
,并keyboardDismissMode
按照其他地方的建议,但它不起作用。
没有要更新的父 ScrollViews、ListViews 或 FlatLists,但是这个组件在里面Modal
,由SafeAreaView
<KeyboardAvoidingView style={{ position: 'absolute', bottom: this.props.bottomHeight, left: 0, right: 0, height: this.props.height }}>
// not sure if I need this inner scrollview, ideally it should just be a view
<ScrollView style={this._computeBottomContainer()} keyboardShouldPersistTaps="always" keyboardDismissMode="on-drag">
<TextInput
style={styles.filter}
placeholder="Type to filter tags"
onChangeText={(text) => this.props.suggestTags(text)}
selectionColor="black"
blurOnSubmit={false}
/>
{ this.props.keyboardOpen &&
<View style={styles.tagsOuterContainer}>
<Text style={styles.suggest}>Suggested tags: {this.props.suggestedTags.length}</Text>
<View style={styles.tagsInnerContainer}>
<FlatList
data={this.props.suggestedTags}
horizontal={true}
renderItem={this.renderTag}
keyExtractor={( {item}, index) => item + index}
keyboardShouldPersistTaps='always'
keyboardDismissMode='on-drag'
/>
</View>
</View>
}
</ScrollView>
</KeyboardAvoidingView>