From 540bc0e9392e258da9b8f9f369560867096c4e28 Mon Sep 17 00:00:00 2001 From: Soner Yuksel Date: Mon, 18 Dec 2023 16:19:22 -0500 Subject: [PATCH 1/2] Update the url bar if it is invoked from NTP directly using the webview display url result --- .../Brave/Frontend/Browser/BrowserViewController.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController.swift index e1966b89a46..2b3f22b94d5 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController.swift @@ -1755,6 +1755,14 @@ public class BrowserViewController: UIViewController { navigateInTab(tab: tab) } else { updateURLBar() + // If navigation will start from NTP, tab display url will be nil until + // didCommit is called and it will cause url bar be empty in that period + // To fix this when tab display url is empty, webview url is used + if tab.url?.displayURL == nil { + if let url = webView.url, !InternalURL.isValid(url: url) { + updateToolbarCurrentURL(url.displayURL) + } + } } // Rewards reporting From 473661b8c5a8f5af901c304ad6e40e450a66360b Mon Sep 17 00:00:00 2001 From: Soner Yuksel Date: Mon, 18 Dec 2023 16:22:49 -0500 Subject: [PATCH 2/2] url shown cant be local url --- Sources/Brave/Frontend/Browser/BrowserViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController.swift index 2b3f22b94d5..7a65c1c8daf 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController.swift @@ -1759,7 +1759,7 @@ public class BrowserViewController: UIViewController { // didCommit is called and it will cause url bar be empty in that period // To fix this when tab display url is empty, webview url is used if tab.url?.displayURL == nil { - if let url = webView.url, !InternalURL.isValid(url: url) { + if let url = webView.url, !url.isLocal, !InternalURL.isValid(url: url) { updateToolbarCurrentURL(url.displayURL) } }