From 46ce824b98504606b867a2da962dc1e64e8a48f7 Mon Sep 17 00:00:00 2001 From: Brian Sanders Date: Thu, 14 May 2020 07:20:40 -0400 Subject: [PATCH] Adds guard against empty search strings to Find in Article --- iOS/Article/WebViewController.swift | 1 + iOS/Resources/main_ios.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index b8792b689..5a6014ade 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -709,6 +709,7 @@ internal struct FindInArticleState: Codable { } extension WebViewController { + func searchText(_ searchText: String, completionHandler: @escaping (FindInArticleState) -> Void) { guard let json = try? JSONEncoder().encode(FindInArticleOptions(text: searchText)) else { return diff --git a/iOS/Resources/main_ios.js b/iOS/Resources/main_ios.js index e19200d3d..6f02ba28f 100644 --- a/iOS/Resources/main_ios.js +++ b/iOS/Resources/main_ios.js @@ -429,6 +429,11 @@ updateFind = withEncodedArg(options => { // TODO Introduce slight delay, cap the number of results, and report results asynchronously let newFindState; + if (!options || !options.text) { + clearHighlightRects(); + return + } + try { newFindState = new FindState(options); } catch (err) {