Skip to content

Commit

Permalink
Fix alert from iframes (#2143)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepimenta authored Jan 20, 2021
1 parent b17b87f commit 431eb9d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions patches/react-native-webview+11.0.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,26 @@ index 2190ae7..cd05399 100644
final String url = request.getUrl().toString();
return this.shouldOverrideUrlLoading(view, url);
}
diff --git a/node_modules/react-native-webview/apple/RNCWebView.m b/node_modules/react-native-webview/apple/RNCWebView.m
index 02005db..c9b51d9 100644
--- a/node_modules/react-native-webview/apple/RNCWebView.m
+++ b/node_modules/react-native-webview/apple/RNCWebView.m
@@ -801,11 +801,13 @@ - (void) webView:(WKWebView *)webView
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
{
#if !TARGET_OS_OSX
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
- [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- completionHandler();
- }]];
- [[self topViewController] presentViewController:alert animated:YES completion:NULL];
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
+ [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+ completionHandler();
+ }]];
+ [[self topViewController] presentViewController:alert animated:YES completion:NULL];
+ });
#else
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:message];

0 comments on commit 431eb9d

Please sign in to comment.