Skip to content

Text disapper after select an item from drop down list #90

@cksiow

Description

@cksiow

When using the component setting as below
<SearchableDropdown
ref={control => this.placeTypeControl = control}
onItemSelect={(item) => {
this.state.saveData.placeTypeId = item.id;
this.setState({});
}}
containerStyle={{ marginTop: 10 }}
itemStyle={{
padding: 10,
marginTop: 2,
backgroundColor: 'white',
borderColor: '#bbb',
borderWidth: 1,
borderRadius: 5,
}}
itemTextStyle={{ color: '#222' }}
itemsContainerStyle={{ height: 125 }}
items={this.state.placeType}
resetValue={false}
textInputProps={
{
placeholder: "",
underlineColorAndroid: "transparent",
style: {
paddingTop: 12,
paddingBottom: 12,
fontSize: 20,
borderWidth: 1,
borderColor: 'black',
borderRadius: 0,
},
onSelectionChange: (e) => {
this.state.saveData.placeTypeId = null;
this.setState({
});
}
}
}
listProps={
{
nestedScrollEnabled: true,
}
}
/>

sample of this.state.placeType
[
{
id: "1",
name: "test1"
},
{
id: "2",
name: "test1"
}
]

after select an item, a while the display text will become blank, after debug and check, found out in onBlur event
this.setState({ focus: false, item: this.props.selectedItems });
change to
this.setState({ focus: false, item: this.props.selectedItems ? this.props.selectedItems : this.state.item });

will resolve the issuedue to this.props.selectedItems set to undefined after while.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions