Skip to content

Commit 603c141

Browse files
authored
Merge pull request #23 from chatwoot/fix/8-clicking-images-redirect-new-page
fix: Redirect new page when click on attachments
2 parents 276eba3 + c9ddb36 commit 603c141

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/WebView.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { StyleSheet } from 'react-native';
2+
import { StyleSheet, Linking } from 'react-native';
33
import { WebView } from 'react-native-webview';
44
import PropTypes from 'prop-types';
55
import { isJsonString, storeHelper, generateScripts, getMessage } from './utils';
@@ -45,6 +45,15 @@ const WebViewComponent = ({
4545
customAttributes,
4646
});
4747

48+
const onShouldStartLoadWithRequest = (request) => {
49+
if (request.url !== widgetUrl) {
50+
Linking.openURL(request.url);
51+
return false;
52+
}
53+
54+
return true;
55+
};
56+
4857
return (
4958
<WebView
5059
source={{
@@ -74,6 +83,7 @@ const WebViewComponent = ({
7483
domStorageEnabled={true}
7584
style={styles.WebViewStyle}
7685
injectedJavaScript={injectedJavaScript}
86+
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
7787
scrollEnabled
7888
/>
7989
);

0 commit comments

Comments
 (0)