diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController.swift index 2a399c2424b..947ca837433 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController.swift @@ -617,25 +617,25 @@ public class BrowserViewController: UIViewController { fileprivate func updateToolbarStateForTraitCollection(_ newCollection: UITraitCollection, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator? = nil) { let showToolbar = shouldShowFooterForTraitCollection(newCollection) - - topToolbar.setShowToolbar(!showToolbar) - toolbar?.removeFromSuperview() - toolbar?.tabToolbarDelegate = nil - toolbar = nil - bottomTouchArea.isEnabled = showToolbar - - if showToolbar { - toolbar = BottomToolbarView(privateBrowsingManager: privateBrowsingManager) - toolbar?.setSearchButtonState(url: tabManager.selectedTab?.url) - footer.addSubview(toolbar!) - toolbar?.tabToolbarDelegate = self - toolbar?.menuButton.setBadges(Array(topToolbar.menuButton.badges.keys)) + if (showToolbar && toolbar == nil) || (!showToolbar && toolbar != nil) { + topToolbar.setShowToolbar(!showToolbar) + toolbar?.removeFromSuperview() + toolbar?.tabToolbarDelegate = nil + toolbar = nil + bottomTouchArea.isEnabled = showToolbar + + if showToolbar { + toolbar = BottomToolbarView(privateBrowsingManager: privateBrowsingManager) + toolbar?.setSearchButtonState(url: tabManager.selectedTab?.url) + footer.addSubview(toolbar!) + toolbar?.tabToolbarDelegate = self + toolbar?.menuButton.setBadges(Array(topToolbar.menuButton.badges.keys)) + } + updateToolbarUsingTabManager(tabManager) + updateUsingBottomBar(using: newCollection) + + view.setNeedsUpdateConstraints() } - updateToolbarUsingTabManager(tabManager) - updateUsingBottomBar(using: newCollection) - - view.setNeedsUpdateConstraints() - if let tab = tabManager.selectedTab, let webView = tab.webView { updateURLBar()