react-native-multiple-image-picker icon indicating copy to clipboard operation
react-native-multiple-image-picker copied to clipboard

Bug: native view issues with other modals

Open hirbod opened this issue 4 years ago • 2 comments

Hi,

I am running into some issues with the modal presentation and third party libraries (and React Navigation Modal presentation.) As soon as the Picker closes, it automatically closes EVERY other open modal in my app.

I did find a workaround for my react-navigation modal by changing presentation (using react-native-screens) from "modal" to "containedModal". This somehow prevents my modal from closing (prob. other hierarchy which doesn't collide with your "getTopMostViewController" and dismissPicker function) , but I have other third party modals opening after the selection which get closed as soon as this picker closes. I guess this library is messing around with the native navigation controller.

Currently, I have to wrap a setTimeout with 1s to my "openVideoEditor" function (which opens a third party video editor as a modal) after I received a response to make sure ImagePicker has been closed.

This is working for now, but suboptimal, since I am using a magic number and this might not be reliable. Furthermore, the modal should not mess around with other modals.

Another option would be to introduce a prop like "waitAnimationEnd" which could be set to true. This should resolve/reject the promise only after the modal has been closed (eg animation ended). This is still kinda hacky but at least prevents us to use setTimeout. I would prefer a proper fix for that. Would love to make a PR, but I am not a native nor swift developer.

This library does the same: https://github.com/ivpusic/react-native-image-crop-picker https://github.com/ivpusic/react-native-image-crop-picker/blob/633769bf0797266f063bc34f51565d519e0b5474/ios/src/ImageCropPicker.m#L87-L97

hirbod avatar Dec 19 '21 14:12 hirbod

Another option would be to introduce a prop like "waitAnimationEnd" which could be set to true. This should resolve/reject the promise only after the modal has been closed (eg animation ended). This is still kinda hacky but at least prevents us to use setTimeout. I would prefer a proper fix for that. Would love to make a PR, but I am not a native nor swift developer.

Thanks for your contribution. I will look to fix this error.

baronha avatar Dec 20 '21 02:12 baronha

Any progress on this?

hirbod avatar Jan 16 '22 10:01 hirbod