From 05cb0184fc26526b35df468c3aed0b84e90aca54 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Wed, 12 Oct 2022 15:00:00 +0200 Subject: [PATCH] fixed find empty string iOS, updated tests --- .../find_interactions.dart | 11 ++++------- .../FindInteraction/FindInteractionController.swift | 2 +- ios/Classes/InAppWebView/InAppWebView.swift | 6 ++++++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/example/integration_test/find_interaction_controller/find_interactions.dart b/example/integration_test/find_interaction_controller/find_interactions.dart index 144a06be..147bc4a1 100644 --- a/example/integration_test/find_interaction_controller/find_interactions.dart +++ b/example/integration_test/find_interaction_controller/find_interactions.dart @@ -47,10 +47,7 @@ void findInteractions() { await expectLater( findInteractionController.findAll(find: firstSearchText), completes); - if ([TargetPlatform.iOS, TargetPlatform.macOS] - .contains(defaultTargetPlatform)) { - expect(await findInteractionController.getSearchText(), firstSearchText); - } + expect(await findInteractionController.getSearchText(), firstSearchText); if ([TargetPlatform.android].contains(defaultTargetPlatform)) { await Future.delayed(Duration(seconds: 1)); } @@ -62,11 +59,11 @@ void findInteractions() { findInteractionController.findNext(forward: false), completes); await expectLater(findInteractionController.clearMatches(), completes); + const secondSearchText = "text"; + await expectLater( + findInteractionController.setSearchText(secondSearchText), completes); if ([TargetPlatform.iOS, TargetPlatform.macOS] .contains(defaultTargetPlatform)) { - const secondSearchText = "text"; - await expectLater( - findInteractionController.setSearchText(secondSearchText), completes); await expectLater( findInteractionController.presentFindNavigator(), completes); expect(await findInteractionController.getSearchText(), secondSearchText); diff --git a/ios/Classes/FindInteraction/FindInteractionController.swift b/ios/Classes/FindInteraction/FindInteractionController.swift index d23b78ee..9eb93142 100644 --- a/ios/Classes/FindInteraction/FindInteractionController.swift +++ b/ios/Classes/FindInteraction/FindInteractionController.swift @@ -94,7 +94,7 @@ public class FindInteractionController : NSObject, Disposable { if let completionHandler = completionHandler { completionHandler(nil, nil) } - } else { + } else if find != "" { let startSearch = "window.\(JAVASCRIPT_BRIDGE_NAME)._findAllAsync('\(find)');" webView.evaluateJavaScript(startSearch, completionHandler: completionHandler) } diff --git a/ios/Classes/InAppWebView/InAppWebView.swift b/ios/Classes/InAppWebView/InAppWebView.swift index 774602b5..ae509cdd 100755 --- a/ios/Classes/InAppWebView/InAppWebView.swift +++ b/ios/Classes/InAppWebView/InAppWebView.swift @@ -1206,6 +1206,12 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, } } + if #available(iOS 16.0, *) { + if newSettingsMap["isFindInteractionEnabled"] != nil, settings?.isFindInteractionEnabled != newSettings.isFindInteractionEnabled { + isFindInteractionEnabled = newSettings.isFindInteractionEnabled + } + } + scrollView.isScrollEnabled = !(newSettings.disableVerticalScroll && newSettings.disableHorizontalScroll) self.settings = newSettings