-
Notifications
You must be signed in to change notification settings - Fork 24k
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
When Modal Component renders then AppState blur event listener calls in Android #36865
Comments
|
Same issue with latest React Native version also |
tried in Latest React Native version also |
My requirement is like, When App will goes to background i want to hide the Screen content and when the app will comes to foreground i want to show the content by setting and clearing FLAG_SECURE. but focus is changing when Modal/Alert components render in screen @OverRide onWindowFocusChanged method is triggering when Modal component triggers I tried with onPause() and onResume() also but onPause method is triggering with delay so screen content is not hidden when App goes background |
Same issue |
I have the same issue, as well as the same use case. I did do some deep diving into the Android code, and from my understanding, this seems to be caused by the fact that the React Native Modal component is based off the Android Dialog class: https://github.com/facebook/react-native/blob/714b502b0c7a5f897432dbad388c02d3b75b4689/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ModalHostShadowNode.java I'm going to keep looking to see if I can figure out a workaround or something. |
Was any solution found for this issue? |
Facing the same issue as well :( - did anyone find a work around? |
Same thing is happening for me too :( |
In case people still need help on this. I had the same exact requirements as @ims7inc and found a workaround. The workaround involved building my own Android native module, and showing a native Android dialog, with the following steps:
If you're wondering why we don't just show the dialog when pressing "home" instead of using If you're wondering why we don't just use Trying to do this through React led me to nowhere. This was the best approach I could come up with. Hope it helps! |
Any proper solution for this? |
@andydotdaniel Mind if I ask to share your solution |
any work around to this @andydotdaniel @ys-sherzad |
On Android, the To handle this, I created a package that implements the Android Lifecycle API for React Native: https://github.com/douglasjunior/react-native-applifecycle
|
@douglasjunior... you're a legend! 🙌 |
Description
When Modal/Alert component renders in our React Native App the App State goes blur
React Native Version
0.71.6
Output of
npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.6.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 81.42 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
Yarn: 1.22.0 - /usr/local/bin/yarn
npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8512546
Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.6 => 0.71.6
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
When Modal/Alert component renders in our React Native App the App State goes blur
AppState.addEventListener('blur', callback);
here this callback method is triggering
Snack, code example, screenshot, or link to a repository
/**
*/
`/**
Sample React Native App
https://github.com/facebook/react-native
@Format
*/
`
The text was updated successfully, but these errors were encountered: