react-native-modal-selector icon indicating copy to clipboard operation
react-native-modal-selector copied to clipboard

Add prop for onCancel

Open scousino opened this issue 5 years ago • 2 comments

Add a prop that accepts a callback that will execute when the user presses the cancel button.

Right now, I'm manually controlling the visibility of the ModalSelector, but I have no way to when the user has selected cancel other than onModalClose, but I can't use that because I'm manually controlling the visibility.

scousino avatar Oct 30 '20 18:10 scousino

The cancel button fires close() which calls this.props.onModalClose(item). That always fires when the cancel button is pressed. https://github.com/peacechen/react-native-modal-selector/blob/master/index.js#L193

If you're creating the button yourself, you have complete control over its callback. I might not be understanding your question fully. Please submit a PR if a change is required in this library.

peacechen avatar Jul 05 '21 20:07 peacechen

Yes if you look at that exact method you referred to, the close() method sets the visibility of the modal explicitly. However, I'm trying to control the visibility of the Modal manually like the doc indicates. But this explicit setting of the visibility by the package while I'm trying to rightfully be in full control of visibility breaks that functionality/understanding.

scousino avatar Aug 11 '21 15:08 scousino