Search code examples
react-nativemodal-dialogdropdownsearchable

Is it possible to use searchableDropdown inside a Modal (react-native)?


I am trying to use Searchable Dropdown inside a modal in react native.If i use it 'alone' (i mean outside the modal) it works fine.But if i put it inside a modal , its attribute onItemSelect does not seem to work( it does not let me click on anything)

<Modal isVisible={this.state.isBuildingModalVisible}>
                <SearchableDropdown
                  onItemSelect={item => {
                    this.setState({ building_id: item.id });
                  }}
                  containerStyle={{ ...}}
                  textInputStyle={{
                   ...
                  }}
                  itemStyle={{
                   ...
                  }}
                  itemTextStyle={{
                    color: "white",
                    fontSize: (15 / 411.42) * screen
                  }}
                  itemsContainerStyle={{ maxHeight: 140 }}
                  items={this.state.dataSource}
                  placeholder="Choose School"
                  placeholderTextColor="white"
                  underlineColorAndroid="transparent"
                />
                <View
                  style={{
                    alignItems: "center",
                    justifyContent: "center",
                    flexDirection: "row"
                  }}
                >
                  <TouchableOpacity
                    style={styles.button}
                    onPress={this.toggleBuildingModal}
                  >
                    <Text style={{ color: "white" }}>Cancel</Text>
                  </TouchableOpacity>
                  <TouchableOpacity
                    style={styles.button}
                    onPress={() => this.submitpassword()}
                  >
                    <Text style={{ color: "white" }}>Execute</Text>
                  </TouchableOpacity>
                </View>
              </Modal>

Solution

  • Ok the problem was that react native does not allow you to put SearchableDropdown inside scrollview (if anyone has this problem :P)