From e85022065b0c1e9c0ea8cb31aae30b8400189fc7 Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Thu, 5 Oct 2023 12:40:11 -0400 Subject: [PATCH] Fix #8190: Add in-page search to the debug histograms controller --- .../Settings/SettingsViewController.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Sources/Brave/Frontend/Settings/SettingsViewController.swift b/Sources/Brave/Frontend/Settings/SettingsViewController.swift index 043e7b8edd0..0d5a3bc58d6 100644 --- a/Sources/Brave/Frontend/Settings/SettingsViewController.swift +++ b/Sources/Brave/Frontend/Settings/SettingsViewController.swift @@ -780,6 +780,23 @@ class SettingsViewController: TableViewController { let histogramsController = self.p3aUtilities.histogramsController().then { $0.title = "Histograms (p3a)" } + if #available(iOS 16.0, *) { + // TODO: Replace this with property access when exposed from brave-core side + let webView = histogramsController.value(forKey: "_webView") as! WKWebView // swiftlint:disable:this force_cast + webView.isFindInteractionEnabled = true + histogramsController.navigationItem.rightBarButtonItem = UIBarButtonItem( + systemItem: .search, + primaryAction: .init { [weak webView] _ in + guard let webView, + let findInteraction = webView.findInteraction, + !findInteraction.isFindNavigatorVisible else { + return + } + webView.findInteraction?.searchText = "" + webView.findInteraction?.presentFindNavigator(showingReplace: false) + } + ) + } self.navigationController?.pushViewController(histogramsController, animated: true) }, accessory: .disclosureIndicator, cellClass: MultilineValue1Cell.self), Row(