diff --git a/packages/expo-web-browser/CHANGELOG.md b/packages/expo-web-browser/CHANGELOG.md new file mode 100644 index 0000000000000..ab076e05ee176 --- /dev/null +++ b/packages/expo-web-browser/CHANGELOG.md @@ -0,0 +1,13 @@ +# Changelog + +## master + +### 🛠 Breaking changes + +### 🎉 New features + +- Add `readerMode` and `dismissButtonStyle` (iOS) and `enableDefaultShare` (Android) flags for `WebBrowser` ([#7221](https://github.com/expo/expo/pull/7221) by [@LinusU](https://github.com/LinusU)) & [@mczernek](https://github.com/mczernek)) + +### 🐛 Bug fixes + +- Fix `WebBrowser` sending `dismiss` before opening. ([#6743](https://github.com/expo/expo/pull/6743) by [@LucaColonnello](https://github.com/LucaColonnello)) diff --git a/packages/expo-web-browser/build/WebBrowser.js b/packages/expo-web-browser/build/WebBrowser.js index 91daac423d968..832e842a5f86c 100644 --- a/packages/expo-web-browser/build/WebBrowser.js +++ b/packages/expo-web-browser/build/WebBrowser.js @@ -106,7 +106,16 @@ let _redirectHandler = null; // Store the `resolve` function from a Promise to fire when the AppState // returns to active let _onWebBrowserCloseAndroid = null; +// If the initial AppState.currentState is null, we assume that the first call to +// AppState#change event is not actually triggered by a real change, +// is triggered instead by the bridge capturing the current state +// (https://facebook.github.io/react-native/docs/appstate#basic-usage) +let _isAppStateAvailable = AppState.currentState !== null; function _onAppStateChangeAndroid(state) { + if (!_isAppStateAvailable) { + _isAppStateAvailable = true; + return; + } if (state === 'active' && _onWebBrowserCloseAndroid) { _onWebBrowserCloseAndroid(); } diff --git a/packages/expo-web-browser/src/WebBrowser.ts b/packages/expo-web-browser/src/WebBrowser.ts index 37ee736ffcb01..03915912d66b8 100644 --- a/packages/expo-web-browser/src/WebBrowser.ts +++ b/packages/expo-web-browser/src/WebBrowser.ts @@ -149,7 +149,17 @@ let _redirectHandler: ((event: RedirectEvent) => void) | null = null; // returns to active let _onWebBrowserCloseAndroid: null | (() => void) = null; +// If the initial AppState.currentState is null, we assume that the first call to +// AppState#change event is not actually triggered by a real change, +// is triggered instead by the bridge capturing the current state +// (https://facebook.github.io/react-native/docs/appstate#basic-usage) +let _isAppStateAvailable: boolean = AppState.currentState !== null; function _onAppStateChangeAndroid(state: AppStateStatus) { + if (!_isAppStateAvailable) { + _isAppStateAvailable = true; + return; + } + if (state === 'active' && _onWebBrowserCloseAndroid) { _onWebBrowserCloseAndroid(); }