From fd063e3c57fcdbb93a894ccdb63d6ac876db7be4 Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Sun, 17 Dec 2023 16:11:07 +0100 Subject: [PATCH] Fix #8526: Fix the issue of the share button disappearing --- .../Frontend/Browser/BrowserViewController.swift | 12 ++++++++++-- .../BrowserViewController+WKNavigationDelegate.swift | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController.swift index e1966b89a46..5eeb99932e0 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController.swift @@ -651,7 +651,7 @@ public class BrowserViewController: UIViewController { let webView = tab.webView { updateURLBar() navigationToolbar.updateBackStatus(webView.canGoBack) - navigationToolbar.updateForwardStatus(webView.canGoForward) + updateForwardStatusIfNeeded(webView: webView) topToolbar.locationView.loading = tab.loading } @@ -1792,7 +1792,7 @@ public class BrowserViewController: UIViewController { guard tab === tabManager.selectedTab, let canGoForward = change?[.newKey] as? Bool else { break } - + navigationToolbar.updateForwardStatus(canGoForward) case .hasOnlySecureContent: guard let tab = tabManager[webView] else { @@ -1913,6 +1913,14 @@ public class BrowserViewController: UIViewController { } } + func updateForwardStatusIfNeeded(webView: WKWebView) { + if let forwardListItem = webView.backForwardList.forwardList.first, forwardListItem.url.isReaderModeURL { + navigationToolbar.updateForwardStatus(false) + } else { + navigationToolbar.updateForwardStatus(webView.canGoForward) + } + } + func updateUIForReaderHomeStateForTab(_ tab: Tab) { updateURLBar() toolbarVisibilityViewModel.toolbarState = .expanded diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+WKNavigationDelegate.swift b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+WKNavigationDelegate.swift index 11968302b83..c257a185b5b 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+WKNavigationDelegate.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+WKNavigationDelegate.swift @@ -666,6 +666,8 @@ extension BrowserViewController: WKNavigationDelegate { if tabManager.selectedTab === tab { updateUIForReaderHomeStateForTab(tab) } + + updateForwardStatusIfNeeded(webView: webView) } public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {