2

我在屏幕底部有一个文本输入,按下时会扩展为更大的部分,并带有一些选项。bottomHeightheight在键盘打开时增加。

当按下额外容器中的这些预定义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>
4

1 回答 1

0

在我的应用程序的根部,我有一个<Swiper />基本上是 ScrollView 的元素。添加keyboardShouldPersistTaps="always" keyboardDismissMode="on-drag"到 Swiper 作为道具解决了我的问题

于 2020-07-27T21:34:02.440 回答