Skip to content

Commit

Permalink
fix: WebView open external links on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
KestasVenslauskas committed Feb 2, 2025
1 parent 36f3c5a commit 7112fbc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions app/components/safeWebView/SafeAutoHeightWebView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ const SafeAutoHeightWebView: React.FC<React.PropsWithChildren<Props>> = forwardR
const {height: screenHeight} = useWindowDimensions();

const handleShouldLoadWithRequest = useCallback((request: ShouldStartLoadRequest) => {
const isUserClickAction = request.navigationType === 'click';
const isUserClickAction =
Platform.select({
//TODO: on android, navigationType is always 'undefined' even if user clicked on the link.
//Need to find a way to detect user click on android. Or wait for the fix
android: true,
}) ?? request.navigationType === 'click';

if (isUserClickAction) {
//User clicked on the link which should redirect to other page.
Expand All @@ -42,7 +47,8 @@ const SafeAutoHeightWebView: React.FC<React.PropsWithChildren<Props>> = forwardR
if (height > screenHeight && !animationDisabled.current) {
console.log('Disabling animation because of webView height:', height);
navigation.setOptions({
animation: 'none',
animationEnabled: false,
// animation: 'none',
});
animationDisabled.current = true;
}
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-webview (13.10.5):
- react-native-webview (13.13.2):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -3320,7 +3320,7 @@ SPEC CHECKSUMS:
react-native-safe-area-context: 758e894ca5a9bd1868d2a9cfbca7326a2b6bf9dc
react-native-theoplayer: a2a565a2e24c12343f79377be56359088e8ee191
react-native-unistyles: 14ada3d7f8d34adf5feaf6b61611c9a368a6434d
react-native-webview: e2ac125036a6b7554e4fd63c01b1b60c240f5a72
react-native-webview: ff5bc3a981754f60bbd22b6b7faec3a3d082e90e
React-nativeconfig: bf6ea7351e761f3ab837b9fc406576c56492f57a
React-NativeModulesApple: 92c27df6aa50fb9eacf20f2718d4a718efc9d5ff
React-perflogger: 9f21c9e3d8d220833e649a141fed8e5ca08977d9
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"react-native-tab-view": "^4.0.5",
"react-native-theoplayer": "^8.12.0",
"react-native-unistyles": "^2.20.0",
"react-native-webview": "13.10.5",
"react-native-webview": "13.13.2",
"zustand": "^5.0.2"
},
"devDependencies": {
Expand Down

0 comments on commit 7112fbc

Please sign in to comment.