zubairpaizer / react-native-searchable-dropdown

Searchable Dropdown
148 stars 98 forks source link

This is happening in the SINGLE case. #70

Open sari1fatih opened 3 years ago

sari1fatih commented 3 years ago

This is happening in the SINGLE case. This bug after these operations are OnClick and Onleave, it clears the text automatically. This solved. At the same time,

( https://www.npmjs.com/package/react-native-searchable-dropdown ) You have to change on documentation for single . The onItemSelect event need to change. This was 'single'. The user can write directly. To catch this need to change the OnTextChange event. I hope I can help you

<SearchableDropdown onItemSelect={(item) => { let items = this.state.selectedItems; items[0].id = item.id items[0].name = item.name this.setState({ selectedItems: items }); }} containerStyle={{ padding: 5 }} onRemoveItem={(item, index) => { const items = this.state.selectedItems.filter((sitem) => sitem.id !== item.id); this.setState({ selectedItems: items }); }} itemStyle={{ padding: 10, marginTop: 2, backgroundColor: '#ddd', borderColor: '#bbb', borderWidth: 1, borderRadius: 5, }} itemTextStyle={{ color: '#222' }} itemsContainerStyle={{ maxHeight: 140 }} items={items} resetValue={false} textInputProps={ { placeholder: "placeholder", underlineColorAndroid: "transparent", style: { padding: 12, borderWidth: 1, borderColor: '#ccc', borderRadius: 5, }, onTextChange: text => { var item = this.state.selectedItems item[0].name = text this.setState({ selectedItems: item }) } } } listProps={ { nestedScrollEnabled: true, } } />