Skip to content

ModalSelector reset when close modal #179

Description

@EloiseIncrociati

I have a component in my react native app that use a ModalSelector to choose option of type I want. If option A, it shows a button which open a modal to select a date with library react-native-calendars.
When I close the modal without validate the dates I picked, the option in modal selector stay. But if I validate, ModalSelector reset and show my text 'select a type' (initValue) of my ModalSelector. It keep in memory the choice, but didn't show it in ModalSelector.

My ModalSelector at beginning :

                <ModalSelector
                  style={{marginBottom: 15}}
                  optionContainerStyle={{backgroundColor: '#FFFFFF'}}
                  optionTextStyle={{color: '#89559e', fontWeight: 'bold'}}
                  selectTextStyle={{color: '#89559e', fontWeight: '500'}}
                  data={listAbs}
                  initValue={I18n.t(
                    'message.myapp.action.selectionnerType',
                  )}
                  cancelText={I18n.t('message.myapp.action.annuler')}
                  keyExtractor={(item) => item.code}
                  labelExtractor={(item) => item.params.libelle}
                  onChange={(option) => setCodeAbs(option)}
                />

Capture d’écran 2022-09-22 à 10 45 54

If validate the date, go back to this point and didn't keep the option. The result I want :
Capture d’écran 2022-09-22 à 10 50 23
What I have :
Capture d’écran 2022-09-22 à 10 56 31

=> I have the problem because the component was too long, so I dispatch it in different components, the component calendar picker was in another component, and the modal in the parent component. If I put my calendar picker component into the parent component, I dont have the problem I describe here. But its a problem I dont have with the children component selectFile, and same problem with children component select hours which use react-native-calendars too.

The filepicker close itself, we can see the same problem with a react native Alert. When we close it, modal selector reset. Seems it reset when we close modals, but not all modals, i dont understand.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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