Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selected element (item) is not displayed #167

Open
chrimoe opened this issue Jul 29, 2021 · 8 comments
Open

Selected element (item) is not displayed #167

chrimoe opened this issue Jul 29, 2021 · 8 comments

Comments

@chrimoe
Copy link

chrimoe commented Jul 29, 2021

The selected element (data: label & key) is adopted, but not displayed in the selector field.
The style properties are also not adopted!!!

The code for the selector:
<ModalSelector
data={data}
ref={selector => {this.selector = selector;}}
overlayStyle={styles.dropdownselector}
caseSensitiveSearch={true}
initValue="Bitte Artikeltyp auswählen!"
supportedOrientations={['landscape']}
accessible={true}
cancelText="zurück"
scrollViewAccessible={true}
scrollViewAccessibilityLabel={'Scrollable options'}
searchText="Suche"
searchTextStyle={{
fontFamily: 'sans-serif',
fontSize: 18,
textAlign: 'center'}}
onChange={(item)=> this.handleChange(item.label, 'itemcat') }>

                </ModalSelector>

Style properties:
const styles = StyleSheet.create({
...
dropdownselector: {
borderColor: 'deepskyblue',
borderRadius: 8,
borderWidth: 1,
height: 40,
padding: 10,
marginBottom: 15,
backgroundColor: '#fafafa',
},
...

@mikaello
Copy link
Collaborator

mikaello commented Sep 2, 2021

Would it possible for you to link an Expo Snack (https://snack.expo.dev/) with a reproducible example of the error you are experiencing? Then it will be easier to see out what could be causing the error.

@solisoft
Copy link

solisoft commented Sep 7, 2021

I have the same issue which occur only when I do a this.setState({ myvar: option.key }) in the onChange callback

@solisoft
Copy link

solisoft commented Sep 7, 2021

<ModalSelector  data={data}  onChange={(option) => { console.log(option) }} />

works fine but

<ModalSelector   data={data}  onChange={(option) => { this.setState({ myvar: option.key }) } />

Don't display the selected value

@solisoft
Copy link

solisoft commented Sep 7, 2021

Actually when I run a setState it erase the selector

@solisoft
Copy link

solisoft commented Sep 7, 2021

I fixed my issue by using selectedKey={this.state.myvar}

@EloiseIncrociati
Copy link

EloiseIncrociati commented Sep 19, 2022

For thoose who had the same problem, but already had a selectedKey prop, on ios, if you do :
onChange={(option) => setModalSelector(option.id)}

go check the issue : https://github.com/peacechen/react-native-modal-selector/issues/140 and change the onChange props into onModalClose :
onModalClose={(option) => setModalSelector(option.id)}

or if you don't use the hooks onModalClose={(option) => {this.setState({ modalSelector: option.id }) }

@ttnunes
Copy link

ttnunes commented Mar 29, 2023

I fixed my issue by using selectedKey={this.state.myvar}

This solution works fine to me! Thank you so much @solisoft

@jmada
Copy link

jmada commented Sep 8, 2023

I fixed my issue by using selectedKey={this.state.myvar}

Thank you so much, it works fine!

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

No branches or pull requests

6 participants