Skip to content

Conversation

sari1fatih
Copy link

@sari1fatih sari1fatih commented May 13, 2021

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,
}
}
/>

After these operations are OnClick and Onleave, it clears the text automatically. This solved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant