diff --git a/.changeset/happy-snails-sleep.md b/.changeset/happy-snails-sleep.md new file mode 100644 index 000000000..0ce471395 --- /dev/null +++ b/.changeset/happy-snails-sleep.md @@ -0,0 +1,5 @@ +--- +'@phantom/react-native-webview': patch +--- + +Prevent showing beforeunload event alerts and always allow proceeding diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java b/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java index 7c0131811..6dab254a9 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java +++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java @@ -511,4 +511,10 @@ public boolean onJsPrompt(WebView view, String url, String message, String defau } return false; } + + @Override + public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) { + result.confirm(); + return true; // Consumed - don't show default dialog + } }