From 3ed8c44ba71c9ccd6c00bac9f5c9d0f13a2c9cb1 Mon Sep 17 00:00:00 2001 From: Artem Chaikin Date: Wed, 26 Apr 2023 17:27:42 +0100 Subject: [PATCH] Fix brave/brave-ios#7260: Don't auto submit URL from a QR code (brave/brave-ios#7319) --- .../Frontend/Browser/BrowserViewController.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController.swift index cec09c654276..2e82f88e928b 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController.swift @@ -1968,11 +1968,11 @@ public class BrowserViewController: UIViewController { present(settingsNavigationController, animated: true) } - func popToBVC() { + func popToBVC(completion: (() -> Void)? = nil) { guard let currentViewController = navigationController?.topViewController else { return } - currentViewController.dismiss(animated: true, completion: nil) + currentViewController.dismiss(animated: true, completion: completion) if currentViewController != self { _ = self.navigationController?.popViewController(animated: true) @@ -2411,8 +2411,11 @@ public class BrowserViewController: UIViewController { extension BrowserViewController { func didScanQRCodeWithURL(_ url: URL) { - popToBVC() - finishEditingAndSubmit(url, visitType: .typed) + let overlayText = URLFormatter.formatURL(url.absoluteString, formatTypes: [], unescapeOptions: []) + + popToBVC() { + self.topToolbar.enterOverlayMode(overlayText, pasted: false, search: false) + } if !url.isBookmarklet && !PrivateBrowsingManager.shared.isPrivateBrowsing { RecentSearch.addItem(type: .qrCode, text: nil, websiteUrl: url.absoluteString)