Open Bilal-Abdeen opened 5 years ago
this.yieldRef._toggleSelector();
const obj = {
id: value[0],
name: value[0]
}
items.push(obj)
this.setState({selectedYield: value});
Altogether simple pass this function onSelectedItemsChange
changeYieldText = value => {
this.yieldRef._toggleSelector();
const obj = {
id: value[0],
name: value[0]
}
items.push(obj)
this.setState({selectedYield: value});
}
But one think to note: this is only for newly added items, for previous existing items in list you don't need to push to the existing array. Otherwise it will duplicated.
Issue summary
SCENARIO DESCRIPTION: (A) The prop "single" is set to true (B) The prop "canAddItems" is set to true (C) The prop "onSelectedItemsChange" is set to {(selectedItems) => { this.setState({ selectedItems: selectedItems, }); }} (D) The prop "selectedItems" is set to {this.state.selectedItems} (1) End User selects an existing option, e.g. Green (2) End User manually enters a new option (instead of the previously selcted option), e.g. ABC
DESIRED RESULT: -> ONLY the manually eneterd option (ABC) is selcted.
ACTUAL RESULT (WHICH IS INCORRECT): -> Both options are selected (Green & ABC).
WORKAROUND: Remove the prop "selectedItems". By doing so, you lose the functionality of dynamically changing the dropdwon label (the prop "selectText") into the selected option.
To get this functionality, you can use the following code for the prop "selectText".
selectText={this.state.demo1_SelectedItems.length === 0 ? "Demo 1 Field" : this.state.demo1_SelectedItems[0]}
Library versions
expo: 32.0.0 react-native: "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz" react-native-multiple-select: 0.5.3
Reproducible Code
WORKAROUND CODE: